Plotting tangent vector on helix shaped plot

조회 수: 22(최근 30일)
답변: 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;
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 2015년 7월 16일
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)
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))
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)
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;
plot3(u(s),v(s),w(s));
end
• 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:

댓글을 달려면 로그인하십시오.

범주

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

Translated by