Plotting the Tangent Line

3 vues (au cours des 30 derniers jours)
Jay Gersten
Jay Gersten le 29 Oct 2015
Commenté : Elioth Daniel le 13 Oct 2022
I am trying to plot the tangent line to a curve given by the parametric equations x = sin(t), y = cos(t), z = t
I have no idea where to start, but here is the code I have for the equations.
t=linspace(0,2*pi,50);
x=cos(t); y=sin(t); z=t;
plot3(x,y,z, 'r', 'LineWidth', 2);
view([2 2 2]); grid on

Réponses (1)

Tushar Sinha
Tushar Sinha le 2 Nov 2015
Hi Jay,
In your case, the parameterized helix curve is given by the equations:
t=linspace(0,2*pi,50);
x=cos(t); y=sin(t); z=t;
The tangent direction < u,v,w > at point < x,y,z > can be calculated as the gradient of the above parameterized equations:
u = -sin(t)
v = cos(t)
w = 1
Now, any tangent line on this curve passing through a point < x,y,z > will be in direction of < u,v,w >. This modifies the above equations as follows:
u = x y
v = y + x
w = z + 1
In order to draw a line passing through a given point < x,y,z > and in the gradient direction, Let s = linspace(-0.75, 0.75, 50).
The following code will draw the tangents at every 10th point on the helix curve:
function tangentCurve
t=linspace(0,2*pi,50);
x=cos(t); y=sin(t); z=t;
figure;
plot3(x,y,z,'r');hold on;
view([2 2 2]); grid on
s = linspace(-0.75, 0.75, 50);
for i = 1:10:length(x)
u=@(s)x(i)-y(i)*s;
v=@(s)y(i)+x(i)*s;
w=@(s)z(i)+1*s;
plot3(u(s),v(s),w(s));
end
end
I hope this helps resolve the issue.
Thanks,
Tushar
  1 commentaire
Elioth Daniel
Elioth Daniel le 13 Oct 2022
Thank you, This helped me very much!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by