% this is a demo for parametric curves % o = [2,2,0]; % origin will be shifted otherwise we won't see the arrows inside our ellipsoid arrow3([0,0,0], [1,0,0],'yellow'); arrow3([0,0,0], [0,1,0],'yellow'); arrow3([0,0,0], [0,0,1],'magenta'); % this plots the i,j,k, vectors xmin = -2; xmax = 2; % plotting window %% Example 1. Spiral tube. Compare with the previous equation! % % its equation is r = <(2 +sin v)*cos u, (2+sinv) sin u, cos v> du = pi/48; dv = pi/48; [u,v] = meshgrid(0:du:2*pi, 0:du:2*pi); X = (2 + sin(v)).*cos(u); Y = (2 + sin(v)).*sin(u); Z = cos(v); surf(X,Y,Z,'FaceColor',[0.8 1 0.8]); % surface plotting % now plot the traces u0 = pi; x = (2 + sin(v)).*cos(u0); y = (2 + sin(v)).*sin(u0); z = cos(v); hold on plot3(x,y,z,... 'r','LineWidth',3); v0 = pi; u1 = (0:du:2*pi)'; x = (2 + sin(v0))*cos(u1); y = (2 + sin(v0))*sin(u1); z = u1*0 + cos(v0); plot3(x,y,z,... 'LineWidth',3); %% now plot the tangent plane at u = pi, v = pi; this is around the point <-2, 0, -1> [X,Y] = meshgrid(-3:0.2:-1, -1:0.2:1); Z = X*0 - 1; surf(X,Y,Z,'FaceColor',[1 1 0.5]);