- Note: For better visualization, try drawing tangents on fewer points rather than all of the possible points on the curve. I have taken an interval of 100 points, it can be modified as needed.
Plotting tangent vector on helix shaped plot
4 views (last 30 days)
Show older comments
I have a plot of a helix, the position of the helix is given by:
omega = 0.1;
angle = omega*t;
radius = 1;
x = radius*cos(angle);
y = radius*sin(angle);
z = vz.*t + 0;
This works & yields a plot as seen below.
What I would like to do, is plot the tangent vector along this plot, quiver3 does not seem to work for this. What would you suggest I do to make this work? Thanks.
My full code is attached.
0 Comments
Accepted Answer
Rahul Goel
on 16 Jul 2015
Hi Adam,
In your case, the helix is a curve parameterized by
f(t) = <x(t), y(t), z(t)>
For any point f(t0) = < x(t0), y(t0), z(t0) > on the curve, the line through f(t0) in the gradient direction will be the tangent line to the curve. This will be true for all points xi, yi, zi on the curve.
For the given curve,
x = r*cos(omega*t)
y = r*sin(omega*t)
z = (q_pipe/pipe_rad*ones(size(vy)) * t
So, tangent direction < u,v,w > at point < x,y,z > can be calculated as the gradient of the above parameterized equations:
u = r*(-sin(omega*t))
v = r*(cos(omega*t))
w = q_pipe/pipe_rad
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 %%x = r*cos(omega*t), y = r*sin(omega*t)
v = y + x %%x = r*cos(omega*t), y = r*sin(omega*t)
w = z + q_pipe/pipe_rad %%z = (q_pipe/pipe_rad*ones(size(vy)) * t
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 100th point on the helix curve:
for i = 1:100:length(x),
u=@(s)x(i)-y(i)*s;
v=@(s)y(i)+x(i)*s;
w=@(s)z(i)+q_pipe/pipe_rad*s;
plot3(u(s),v(s),w(s));
end
When this graph is plotted with the script you provided, it produces following tangents:
Another view from a different angle:
0 Comments
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots 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!