我编写了一个代码来生成螺旋的x,y,z点并得到了这个结果:码:
清除所有;删除所有,clc;%螺旋常数THETA_0 = 5; % 不变THETA_1 = 10.3; %起始角度A = 3 ….
你的第二张照片给你:
u
v
您拥有创建几何图形的所有必要信息:
%plot the mesh u=linspace(0,4*pi,50); v=linspace(0,2*pi,50); [u,v]=meshgrid(u,v); x=(1.2+0.5*cos(v)).*cos(u); y=(1.2+0.5*cos(v)).*sin(u); z=0.5*sin(v)+u/pi; surf(x,y,z) hold on %plot the 3d line u = linspace(0,4*pi,40) x=1.2.*cos(u); y=1.2.*sin(u); z=u/pi; plot3(x,y,z,'r'); axis equal
现在您只需调整参数方程以适合您的线。
的 编辑: 强> 要将相同的解决方案应用于您的特定情况,您只需更换即可 u 和 v 跟你的 theta 和 R 变量在 meshgrid 功能:
theta
R
meshgrid
THETA_0 = 5; % constant THETA_1 = 10.3; % starting angle A = 3.762; B = 0.001317; C = 7.967; D = 0.1287; E = 0.003056; s=2; % Calculate (x,y,z) coordinates of points defining the spiral path theta = THETA_1:5:910.3; for i = 1:length(theta) if (theta(i)<=99.9) R(i) = s*C*(1-D*log(theta(i)-THETA_0)); else R(i) = s*A*exp(-B*theta(i)); end end x = R.*cosd(theta); y = R.*sind(theta); z = E.*(theta-THETA_1); plot3(x,y,z,'r','linewidth',2) hold on [u,v]=meshgrid(theta,R); x=(R+0.5*cos(v)).*cosd(u); y=(R+0.5*cos(v)).*sind(u); z=0.5*sin(v)+E.*(u-THETA_1); mesh(x,y,z,'facecolor','none') axis equal
的 结果: 强>
顺便说一句,我不是混音的忠实粉丝 cosd 和 cos 在相同的脚本中,但做你想要的。
cosd
cos