Appendix C. File

The following file is not a complete program. It is the code for a single class, Obj3D, which is discussed in Section 5.5 and used in the programs of Chapter 5, of Chapter 6, of Section 7.3, and of Section 7.4.

// A 3D object and its 2D representation.
// Uses: Point2D (Section 1.5), Point3D (Section 3.9),
//       Polygon3D, Input (Section 5.5).
import java.awt.*;
import java.util.*;

class Obj3D
{  private float rho, d, theta=0.30F, phi=1.3F, rhoMin, rhoMax,
      xMin, xMax, yMin, yMax, zMin, zMax, v11, v12, v13, v21,
      v22, v23, v32, v33, v43, xe, ye, ze, objSize;
   private Point2D imgCenter;
   private double sunZ = 1/Math.sqrt (3) , sunY = sunZ, sunX = -sunZ,
      inprodMin = 1e30, inprodMax = −1e30, inprodRange;
   private Vector w = new Vector();         // World coordinates
   private Point3D[] e;                     // Eye coordinates
   private Point2D[] vScr;                  // Screen coordinates
   private Vector polyList = new Vector();  // Polygon3D objects
private String fName = " "; // File name boolean read(String fName) { Input inp = new Input(fName); if (inp.fails())return failing(); this.fName = fName; xMin = yMin = zMin = +1e30F; xMax = yMax = zMax = −1e30F; return readObject(inp); // Read from inp into obj } Vector getPolyList(){return polyList;} String getFName(){return fName;} Point3D[] getE(){return e;} Point2D[] getVScr(){return vScr;} Point2D getImgCenter(){return imgCenter;} float getRho(){return rho;} float getD(){return d;} private boolean failing() ...

Get Computer Graphics for Java Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.