/****************************************************** * SURFACES OF PARAMETRIC EQUATIONS * * --------------------------------------------------- * * This program draws 3D surfaces defined by equations * * x = f(u,v), y = g(u,v), z = h(u,v) by using unit * * graph_3d.pas. * * --------------------------------------------------- * * SAMPLE RUN: * * * * Surface Data: * * ============= * * * * Surface Type: 1. Ellipsoid * * 2. Sphere * * 3. Torus * * 4. Hyperboloid * * Your choice(1 to 4): 1 * * * * Projection type (1:perspective 2:parallel) * * Your choice(1 or 2): 2 * * * * Value of distance to screen: 30 * * Value of angle Theta (deg.): 60 * * Value of angle Phi (deg.): 30 * * * * Input U begin, U end and step: -1.57 1.57 0.2 * * Input V begin, V end and step: -3.14 3.14 0.2 * * (An ellipsoid is displayed in parralel mode). * * * * Your choice(1 to 4): 2 * * * * Value of distance to screen: 25 * * Value of angle Theta (deg.): 45 * * Value of angle Phi (deg.): 30 * * * * Input U begin, U end and step: -3.14 3.14 0.2 * * Input V begin, V end and step: -3.14 3.14 0.2 * * (A shere is displayed in parralel mode). * * * * Your choice(1 to 4): 3 * * * * Value of distance to screen: 20 * * Value of angle Theta (deg.): 30 * * Value of angle Phi (deg.): 30 * * * * Input U begin, U end and step: -3.14 3.14 0.4 * * Input V begin, V end and step: -3.14 3.14 0.2 * * (A torus is displayed in parralel mode). * * * * Your choice(1 to 4): 4 * * * * Value of distance to screen: 100 * * Value of angle Theta (deg.): 60 * * Value of angle Phi (deg.): 30 * * * * Input U begin, U end and step: -1 1 0.1 * * Input V begin, V end and step: -1 1 0.1 * * (An hyperpoloid is displayed in parralel mode). * * * * Your choice(1 to 4): 3 * * * * Projection type (1:perspective 2:parallel) * * Your choice(1 or 2): 1 * * * * Value of Rho : 150 * * Value of distance to screen: 2500 * * Value of angle Theta (deg.): 30 * * Value of angle Phi (deg.): 30 * * * * Input U begin, U end and step: -3.14 3.14 0.4 * * Input V begin, V end and step: -3.14 3.14 0.2 * * (A torus is displayed in perspective mode). * * * * --------------------------------------------------- * * Ref.: "Graphisme dans le plan et dans l'espace en * * Turbo Pascal 4.0 By R. Dony, MASSON Paris, * * 1990" [BIBLI 12]. * * * * C++ Release in API style By J-P Moreau, Paris.* * (www.jpmoreau.fr) * ******************************************************* NOTE: In perspective mode, for a given rho value, you can increase the dimension of object by increasing the value of distance to screen (see last sample run). -----------------------------------------------------*/ #include #include #include #define perspective 1 #define parallele 2 HDC hdc; RECT rect; //Functions used here of module Graph_3D //define drawing zone (ix1,ix2,iy1,iy2) in screen pixels void Cloture(int,int,int,int); //draw a frame around drawing zone (optional) void Bordure(); //MoveTo(x,y,z) in physical coordinates (pen is up) void MoveXYZ(double,double,double); //LineTo(x,y,z) in physical coordinates (pen is down) void LineXYZ(double,double,double); //Draw axes X,Y,Z void Axes(double,double,double); //calculate auxiliary projection variables void InitProj(void); //"home made" graphic commands for hdc environment used by above functions void DrawPixel(int ix,int iy) { //sorry, no other available command found Rectangle(hdc,rect.left+ix,rect.top+iy, rect.left+ix+2,rect.top+iy+1); } void Swap(int *i1,int *i2) { int it; it=*i1; *i1=*i2; *i2=it; } void DrawLine(int ix1,int iy1,int ix2,int iy2) { int i,il,ix,iy; float dx,dy; if (ix2