Clear Filters
Clear Filters

Plotting the Tangent Line

4 views (last 30 days)
Jay Gersten
Jay Gersten on 29 Oct 2015
Commented: Elioth Daniel on 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

Answers (1)

Tushar Sinha
Tushar Sinha on 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

Categories

Find more on Bounding Regions 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!