Appendix D. Class CvHLines.java

The following class is used in program HLines.java, listed in Section 6.8:

// CvHLines.java: Used in the file HLines.java.
import java.awt.*;
import java.util.*;

class CvHLines extends Canvas3D
{  private int maxX, maxY, centerX, centerY, nTria, nVertices;
   private Obj3D obj;
   private Point2D imgCenter;
   private Tria[] tr;
   private HPGL hpgl;
   private int[] refPol;
   private int[][] connect;
   private int[] nConnect;
   private int chunkSize = 4;
   private double hLimit;
   private Vector polyList;
   private float maxScreenRange;

   Obj3D getObj(){return obj;}
   void setObj(Obj3D obj){this.obj = obj;}
void setHPGL(HPGL hpgl){this.hpgl = hpgl;} public void paint(Graphics g) { if (obj == null) return; Vector polyList = obj.getPolyList(); if (polyList == null) return; int nFaces = polyList.size(); if (nFaces == 0) return; float xe, ye, ze; Dimension dim = getSize(); maxX = dim.width - 1; maxY = dim.height - 1; centerX = maxX/2; centerY = maxY/2; // ze-axis towards eye, so ze-coordinates of // object points are all negative. Since screen // coordinates x and y are used to interpolate for // the z-direction, we have to deal with 1/z instead // of z. With negative z, a small value of 1/z means // a small value of |z| for a nearby point. // obj is a java object that contains all data, // with w, e and vScr parallel (with vertex numbers // as index values): // - Vector w (with Point3D elements) // - Array e (with Point3D elements) // - Array vScr (with Point2D elements) // - Vector ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.