1
votes

I'm trying to create 3D plots in Matlab, and I have practically no experience. I'd really like to draw the figure described by these equations:

x = cos(u) sinh(t) / (cosh(t) - cos(u));    
y = cos(u) sin(u) / (cosh(t) - cos(u));    
z = sin(u);

where both u and t vary from -pi to pi. This is what Paul Bourke calls Ghost Plane.

clc
clear
a = -pi:.01:pi;
b = -pi:.01:pi;
[U,T] = meshgrid(a,b);
X = (cos(U).*sinh(T))./(cosh(T)-cos(U));
Y = (cos(U).*sin(U))./(cosh(T)-cos(U));
Z = sin(U);
figure
surf(X,Y,Z)

With the code, I get something... indescribable. How do I plot the figure?

1

1 Answers

3
votes

Your code is correct. You just need to zoom in.

Some tips to make this more viewable:

  • Use less fine grids, by changing a = ... and b = ... to: linspace(-pi,pi,40);

  • Add this ,'FaceColor','none','EdgeColor','interp'); to the surf command to only plot the lines and those in color.

  • Add this axis equal vis3d; after the surf command, so the axis will have correct scaling and behave well while rotating.

  • Add whitebg('black'); and grid off; to make the background black.

  • Change to surf(X,Y,Z,-U,...); and add colormap('HSV'); if you want the same colors as in the original.

  • set(gca,'xtick',[]); set(gca,'xticklabel',[]); set(gca,'yticklabel',[]); set(gca,'ytick',[]); to remove the axis ticks

  • You might want to use the cameratoolbar to: Change the projection to perspective projection, zoom all the way out, move the camera in very close, to get nice perspective distortions.

VoilĂ :

Plot