Intersection of Parametric Curves Using vpasolve
Show older comments
I'm trying to find the intersections of two parametric curves. I thought it was solved until i zoomed in to see a significant error.
I'm not sure what's going on.
Any help would be appreciated. Thank you.
Problem: Graph the cycloid

and the trochoid

together on the interval [0, 4π]. Find the coordinates of the four points of intersection. (Hint: Solve the equation r(t) = s(u). Note the different independent variables for r and s—the points of intersection need not correspond to the same “time” on each curve. Also, since the coordinate functions are transcendental, you may need to use vpasolve rather than solve.) Use MATLAB to mark the four points on your graph.
From Multivariable Calculus with MATLAB: With Applications to Geometry and Physics 1st ed. 2017 (Lispman, Rosenberg). This is Problem 2.21. Page 29.
Define curves
syms ind t u;
rx(ind)=2*(ind)-2*sin(ind);
ry(ind)=2*(1-cos(ind));
sx(ind)=2*(ind)-sin(ind);
sy(ind)=2-cos(ind);
figure;hold on;xlim([0 25]);
fplot(rx(t),ry(t),[0 4*pi],'b');
fplot(sx(u),sy(u),[0 4*pi],'r');
xlabel('r_x(t) ~ s_x(u)');
ylabel('r_y(t) ~ s_x(u)');
From inspection (see see first plot below), intersections ocurr where r(t) is approximately {1, 12 13 24}. The x component of r(t) is approximately double t. So approximations for t are t=1/2{1,12,13,24}. Also note that
and
remain approximately close in value as t and u vary.
guesses=[1, 12 13 24]/2;
Setup the system to solve:
(eq)
(eq)eq=[rx(t) ry(t)]-[sx(u) sy(u)]==0;
For each guess, solve eq for t and u (using vpasolve).
for guess=guesses
solution=vpasolve(eq,[t u],guess);
Plot the intersection point Pn. Plot r(t) with a large blue dot and s(u) as a small yellow dot.
plot(rx(solution.t),ry(solution.t),'b.','markersize',20); % plot R(t) at t_x = Pn_x
plot(sx(solution.u),sy(solution.u),'y.','markersize',5); % plot S(u) at u_x = Pn_x
Print intersection values of t and u at Pn.
fprintf('R(t) and S(u) intersect at P%d when',find(guesses==guess));
tn=double(solution.t)
un=double(solution.u)
end
hold off;
Zoom-In to see the error
figure; hold on;
fplot(rx(t),ry(t),[0 4*pi],'b');
fplot(sx(u),sy(u),[0 4*pi],'r');
for guess=guesses
solution=vpasolve(eq,[t u],guess);
plot(rx(solution.t),ry(solution.t),'k.','markersize',20); % plot R(t) at Pn
plot(sx(solution.u),sy(solution.u),'g.','markersize',15); % plot S(u) at Pn
end
xlabel('r_x(t) ~ s_x(u)');
ylabel('r_y(t) ~ s_x(u)');
xlim([12.15603 12.15897])
ylim([1.078214 1.078684])
2 Comments
Simon Chan
on 14 Aug 2021
Just wondering why the marker colors are not black and green on the plot for the following code?
plot(rx(solution.t),ry(solution.t),'k.','markersize',20); % plot R(t) at Pn
plot(sx(solution.u),sy(solution.u),'g.','markersize',15); % plot S(u) at Pn
Simon D. Porcella
on 14 Aug 2021
Edited: Simon D. Porcella
on 14 Aug 2021
Accepted Answer
More Answers (0)
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

