# Intersection of Parametric Curves Using vpasolve

조회 수: 18(최근 30일)
Simon Le Serve 2021년 8월 13일
편집: Simon Le Serve 2021년 8월 19일
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=[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
R(t) and S(u) intersect at P1 when
tn = 1.0918
un = 0.3983
R(t) and S(u) intersect at P2 when
tn = 5.1914
un = 5.8849
R(t) and S(u) intersect at P3 when
tn = 7.3750
un = 6.6814
R(t) and S(u) intersect at P4 when
tn = 11.4745
un = 12.1681
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표시숨기기 이전 댓글 수: 1
Simon Le Serve 2021년 8월 14일
hey Simon, thanks you're right!
Not sure though, must have not executed on last edit.
you have a sharp eye!

댓글을 달려면 로그인하십시오.

### 채택된 답변

John D'Errico 2021년 8월 14일
편집: John D'Errico 2021년 8월 14일
Your probem is when you zoomed in. The mathematics seems fine.
>> tn
tn =
11.4745470305524
>> un
un =
12.1681063167797
>> vpa(rx(tn))
ans =
24.724031702281097750999349300293
>> vpa(sx(un))
ans =
24.72403170228109712971250329995
>> vpa(ry(tn))
ans =
1.0782644793999382387376598972632
>> vpa(sy(un))
ans =
1.0782644793999394359320615865557
The MATLAB zoom is not very accurate, not when you zoom in that deeply. It does not re-evaluate those curves, and then give you a hyper-accurate picture. Instead, it gives you a literally microscopic view of the pixels that were plotted.
The numbers are correct. Just that the zoom has confused you.
##### 댓글 수: 3표시숨기기 이전 댓글 수: 2
Simon Le Serve 2021년 8월 14일
I understand now! :)
thanks John

댓글을 달려면 로그인하십시오.

R2021a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!