%% Celestial Sphere Example % This example will demonstrate how to plot and view 3d body and trace from % a given 2d plane. %% Setup Spherical Surface and Trace % Spherical cordinates will be used for the surface %% % % <<3D_Spherical.svg>> % % Spherical Surface in Spherical Cordinates theta1 = linspace(0,360,60); phi1 = linspace(0,180,60); [theta1, phi1] = meshgrid(theta1, phi1); rho1 = 1; % Transform Cordinates of Spherical Surface x1 = rho1*cosd(theta1).*sind(phi1); y1 = rho1*sind(theta1).*sind(phi1); z1 = rho1*cosd(phi1); % Elliptic Trace r_a = 1.25; r_b = 1.75; theta2 = linspace(0,360,120); x2 = r_a*cosd(theta2); y2 = r_b*sind(theta2); z2 = zeros(size(theta2)); % rotate trace 20 degrees % Google cordinate transformaiton for more information beta = 20; transformationMatrix = [cosd(beta) 0 -sin(beta); 0 1 0; sin(beta) 0 cos(beta)]; X2 = transformationMatrix*[x2; y2; z2]; x2 = X2(1,:); y2 = X2(2,:); z2 = X2(3,:); %% Plot and view the Surface and Trace Together screen = get(0,'ScreenSize'); %This gets the dimensions your screen figure('Position',[.2*screen(3) .2*screen(4) 800 800]) surf(x1,y1,z1) hold('on'); plot3(x2,y2,z2) axis('equal'); xlabel('x') ylabel('y') zlabel('z') view([0 0]) figure('Position',[.2*screen(3) .2*screen(4) 800 800]) surf(x1,y1,z1) hold('on'); plot3(x2,y2,z2) axis('equal'); xlabel('x') ylabel('y') zlabel('z') view([90 0])