Skip to Content
Computer Graphics for Java Programmers, Second Edition
book

Computer Graphics for Java Programmers, Second Edition

by Leen Ammeraal, Kang Zhang
March 2007
Intermediate to advanced
386 pages
7h 59m
English
Wiley
Content preview from Computer Graphics for Java Programmers, Second Edition

Appendix C. File Obj3D.java

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 Wireframe.java of Chapter 5, HLines.java of Chapter 6, Painter.java of Section 7.3, and ZBuf.java of Section 7.4.

// Obj3D.java: 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() ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

OpenGL Programming for Windows 95 and Windows NT

OpenGL Programming for Windows 95 and Windows NT

Ron Fosner
Java 2D Graphics

Java 2D Graphics

Jonathan Knudsen

Publisher Resources

ISBN: 9780470031605Purchase book