Borrar filtros
Borrar filtros

Plotting the Tangent Line

4 visualizaciones (últimos 30 días)
Jay Gersten
Jay Gersten el 29 de Oct. de 2015
Comentada: Elioth Daniel el 13 de Oct. de 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

Respuestas (1)

Tushar Sinha
Tushar Sinha el 2 de Nov. de 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 comentario
Elioth Daniel
Elioth Daniel el 13 de Oct. de 2022
Thank you, This helped me very much!

Iniciar sesión para comentar.

Categorías

Más información sobre Bounding Regions en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by