/* * Header Begins--Do not remove################################################ * * C-code driver that exercises the plotting package to produce circles, * spheres and ellipses. * * (c) Eugene Fiume, University of Toronto, 1995. * * You are permitted to use this code for noncommercial, educational * purposes only. This header must not be removed from this file. * * Header Ends--Do not remove################################################## */ #include #include #include "Plot.h" /* * Some useful constants */ #define pi 3.141592654 #define pi4 3.141592654/4.0 #define pi8 3.141592654/8.0 #define nt 24 #define ns 24 /* * Parametric functions for a circle of radius 1. */ double foo(t) double t; { return t; } double circx(t) double t; { return(cos(t)); } /* circx */ double circy(t) double t; { return(sin(t)); } /* circy */ /* * Parametric functions for a sphere of radius 1. */ double sphx(theta, phi) double theta, phi; { return(cos(theta)*sin(phi)); } /* sphx */ double sphy(theta, phi) double theta, phi; { return(sin(theta)*sin(phi)); } /* sphy */ double sphz(theta, phi) double theta, phi; { return(cos(phi)); } /* sphz */ /* * Parametric functions for an ellipse */ double ellx(theta, phi) double theta, phi; { return(1.5*cos(theta)*sin(phi)); } /* ellx */ double elly(theta, phi) double theta, phi; { return(0.75*sin(theta)*sin(phi)); } /* elly */ double ellz(theta, phi) double theta, phi; { return(0.5*cos(phi)); } /* ellz */ main(argc, argv) int argc; char *argv[]; { printf("2D and 3D Plotting Demonstration\n"); XOpen(800,800, argc, argv); /* * Let's plot something */ printf("First, a circle. Hit a mouse button to start.\n"); GetEvent(); SetScale(100.0,100.0); SetOffset(150,150); SetColour(1); Plot2D(circx,circy,0.0,2.0*pi,128); printf("Next, a sphere. Hit a mouse button to continue.\n"); GetEvent(); SetRotation(pi8,pi8,pi8); SetColour(2); SetOffset(500,100); Plot3D(sphx,sphy,sphz, 0.0,2.0*pi,ns, 0.0,pi,nt); printf("Last, an ellipse. Hit a mouse button to continue.\n"); GetEvent(); SetColour(3); SetOffset(400,250); Plot3D(ellx,elly,ellz, 0.0,2.0*pi,ns, 0.0,pi,nt); printf("We're done. Hit a mouse button to stop.\n"); GetEvent(); }