clc; clear;
syms x y z t
%t = linspace(0,2*pi,100);
x = t-sin(t);
y = 1-cos(t);
z = 4.*sin(t./2);
S = jacobian([x,y,z],t) % 曲线方程的切向量(得到x,y,z关于t的导数方程)
![](https://i-blog.csdnimg.cn/blog_migrate/671386630c9fe8339b5506068d108640.png)
t = pi/2;
S0 = subs(S) % 切点处的x,y,z方向分别的切向量
![](https://i-blog.csdnimg.cn/blog_migrate/f9a73c897f570deb2e3751de2c8a94fc.png)
x0 = t-sin(t) % 切点(x0,y0,z0)
y0 = 1-cos(t)
z0 = 4.*sin(t./2)
F = -[x;y;z]+[x0;y0;z0]+S0*t %切线方程
G = [x-x0,y-y0,z-z0]*S0 %法平面方程
![](https://i-blog.csdnimg.cn/blog_migrate/2ea36d0a40f4736c484c235a824915d1.png)
figure
%axis square %坐标轴尺寸正方形
%set(gca,'xtick',[],'ytick',[],'xcolor','w','ycolor','w') %隐藏坐标轴
t = linspace(0,2*pi,100);
x = eval(x);
y = eval(y);
z = eval(z);
plot3(x,y,z)
grid on
xlabel('x')
ylabel('y')
zlabel('z')
hold on
u = -1:0.01:1;
x_Tangent = u.*S0(1)+x0;
y_Tangent = u.*S0(2)+y0;
z_Tangent = u.*S0(3)+z0;
plot3(x_Tangent,y_Tangent,z_Tangent) % 切线
xlab = -1:0.1:1;
[x_normalPlane,y_normalPlane] = meshgrid(xlab);
z_normalPlane = double((-S0(1).*(x_normalPlane-x0)-S0(2).*(y_normalPlane-y0))/S0(3))+z0;
mesh(x_normalPlane,y_normalPlane,z_normalPlane)
![](https://i-blog.csdnimg.cn/blog_migrate/465739dc3df5234cf659d690c25429f3.png)