Plotting the Tangent Line

4 次查看(过去 30 天)
Jay Gersten
Jay Gersten 2015-10-29
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

回答(1 个)

Tushar Sinha
Tushar Sinha 2015-11-2
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

类别

Help CenterFile Exchange 中查找有关 Bounding Regions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by