Plotting tangent vector on helix shaped plot

조회 수: 6 (최근 30일)
Adam Keller
Adam Keller 2015년 7월 13일
답변: Rahul Goel 2015년 7월 16일
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.

채택된 답변

Rahul Goel
Rahul Goel 2015년 7월 16일
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),
  • 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.
When this graph is plotted with the script you provided, it produces following tangents:
Another view from a different angle:

추가 답변 (0개)


Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by