cynosurex.graphics3D
Class Polygon3D

java.lang.Object
  extended by cynosurex.graphics3D.Polygon3D
All Implemented Interfaces:
cynosurex.internal.AuthorCommon, cynosurex.internal.CommonInterface, cynosurex.internal.CompanyCommon

public class Polygon3D
extends java.lang.Object
implements cynosurex.internal.CommonInterface

A polygon consists of a list of x, y, and z coordinates.

Version:
1.0, 10/02/97
Author:
Chieh Cheng

Field Summary
 int npoints
          The number of points in this polygon
 int[] xpoints
          The array of x coordinates.
protected  java.awt.Rectangle XY_bounds
          XY bounds of the polygon.
protected  java.awt.Rectangle XZ_bounds
          XZ bounds of the polygon.
 int[] ypoints
          The array of y coordinates.
protected  java.awt.Rectangle YZ_bounds
          YZ bounds of the polygon.
 int[] zpoints
          The array of z coordinates.
 
Fields inherited from interface cynosurex.internal.CommonInterface
copyright, copyrightYears, notice, program, version
 
Fields inherited from interface cynosurex.internal.AuthorCommon
author, copyrightSymbol, noticeMsg, rights
 
Fields inherited from interface cynosurex.internal.CompanyCommon
company, email, website
 
Constructor Summary
Polygon3D()
          Creates an empty polygon.
Polygon3D(int[] xpoints, int[] ypoints, int[] zpoints, int npoints)
          Constructs and initializes a Polygon from the specified parameters.
 
Method Summary
 void addPoint(int x, int y, int z)
          Appends a point to a polygon.
 boolean contains(int x, int y, int z)
          Determines whether the point (x, y, z) is inside the Polygon.
 boolean contains(Point3D p)
          Determines whether the 3D point is inside the Polygon.
 java.awt.Rectangle getXYBounds()
          Returns the XY bounding box of the shape.
 java.awt.Rectangle getXZBounds()
          Returns the XZ bounding box of the shape.
 java.awt.Rectangle getYZBounds()
          Returns the YZ bounding box of the shape.
 void translate(int deltaX, int deltaY, int deltaZ)
          Translates the vertices by deltaX, deltaY, and deltaZ.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

npoints

public int npoints
The number of points in this polygon


xpoints

public int[] xpoints
The array of x coordinates.


ypoints

public int[] ypoints
The array of y coordinates.


zpoints

public int[] zpoints
The array of z coordinates.


XY_bounds

protected java.awt.Rectangle XY_bounds
XY bounds of the polygon.


YZ_bounds

protected java.awt.Rectangle YZ_bounds
YZ bounds of the polygon.


XZ_bounds

protected java.awt.Rectangle XZ_bounds
XZ bounds of the polygon.

Constructor Detail

Polygon3D

public Polygon3D()
Creates an empty polygon.


Polygon3D

public Polygon3D(int[] xpoints,
                 int[] ypoints,
                 int[] zpoints,
                 int npoints)
Constructs and initializes a Polygon from the specified parameters.

Parameters:
xpoints - the array of x coordinates
ypoints - the array of y coordinates
zpoints - the array of z coordinates
npoints - the total number of points in the Polygon
Method Detail

translate

public void translate(int deltaX,
                      int deltaY,
                      int deltaZ)
Translates the vertices by deltaX, deltaY, and deltaZ.

Parameters:
deltaX - the amount to move the X coords
deltaY - the amount to move the Y coords
deltaZ - the amount to move the Z coords

addPoint

public void addPoint(int x,
                     int y,
                     int z)
Appends a point to a polygon. If 'inside (x, y, z)' or another operation that calculates the bounding box has already been performed, this method updates the bounds accordingly.

Parameters:
x - the x coordinate of the point
y - the y coordinate of the point
z - the z coordinate of the piont

getXYBounds

public java.awt.Rectangle getXYBounds()
Returns the XY bounding box of the shape.

Returns:
a Rectangle defining the XY bounds of the Polygon.

getYZBounds

public java.awt.Rectangle getYZBounds()
Returns the YZ bounding box of the shape.

Returns:
a Rectangle defining the YZ bounds of the Polygon.

getXZBounds

public java.awt.Rectangle getXZBounds()
Returns the XZ bounding box of the shape.

Returns:
a Rectangle defining the XZ bounds of the Polygon.

contains

public boolean contains(Point3D p)
Determines whether the 3D point is inside the Polygon.

Parameters:
p - the point to be tested

contains

public boolean contains(int x,
                        int y,
                        int z)
Determines whether the point (x, y, z) is inside the Polygon.

Parameters:
x - the X coordinate of the point to be tested
y - the Y coordinate of the point to be tested
z - the z coordinate of the point to be tested