Class PlaneEquation

java.lang.Object
  |
  +--PlaneEquation

public class PlaneEquation
extends Object
implements Cloneable

Represents a plane equation for a plane in 3D space.

Author:
Sasmito Adibowo - 1299000029

Field Summary
protected  double A
          The x-coefficient of the equation.
protected  double B
          The y-coefficient of the equation.
protected  double C
          The z-coefficient of the equation.
protected  double D
          The constant value of the equation.
protected  Vector3D normalVector
          The normal vector, cached value from (A,B,C)
 
Constructor Summary
PlaneEquation(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3)
          Creates a plane equation from three (x,y,z) triplets.
PlaneEquation(Mesh.Polygon polygon)
          Creates a plane equation from the first three points in the polygon.
PlaneEquation(Point3D pt1, Point3D pt2, Point3D pt3)
          Creates a plane equation from a set of three points which are on the plane.
 
Method Summary
protected  void calcEquations(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3)
          Calculate the values of A,B,C,D of the plane equation.
protected  void calcNormalVector(Mesh.Polygon polygon)
          Initializes the normalVector variable.
 double calcZ(double x, double y)
          Returns a Z value on the plane given the X and Y values.
 double evaluate(double x, double y, double z)
          Evaluates a point to the plane equation.
 double evaluate(Point3D pt)
          Evaluates a point to the plane equation.
 Vector3D getNormalVector()
          Returns the normal vector.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

A

protected double A
The x-coefficient of the equation.
See Also:
calcEquations(double, double, double, double, double, double, double, double, double)

B

protected double B
The y-coefficient of the equation.
See Also:
calcEquations(double, double, double, double, double, double, double, double, double)

C

protected double C
The z-coefficient of the equation.
See Also:
calcEquations(double, double, double, double, double, double, double, double, double)

D

protected double D
The constant value of the equation.
See Also:
calcEquations(double, double, double, double, double, double, double, double, double)

normalVector

protected Vector3D normalVector
The normal vector, cached value from (A,B,C)
Constructor Detail

PlaneEquation

public PlaneEquation(Mesh.Polygon polygon)
Creates a plane equation from the first three points in the polygon.
Parameters:
polygon - a polygon in a polygon mesh.
See Also:
calcEquations(double, double, double, double, double, double, double, double, double)

PlaneEquation

public PlaneEquation(Point3D pt1,
                     Point3D pt2,
                     Point3D pt3)
Creates a plane equation from a set of three points which are on the plane.
Parameters:
pt1 - the first point.
pt2 - the second point.
pt3 - the third point.
See Also:
calcEquations(double, double, double, double, double, double, double, double, double)

PlaneEquation

public PlaneEquation(double x1,
                     double y1,
                     double z1,
                     double x2,
                     double y2,
                     double z2,
                     double x3,
                     double y3,
                     double z3)
Creates a plane equation from three (x,y,z) triplets.
Parameters:
x1 - The x coordinate of the first point in the plane.
y1 - The y coordinate of the first point in the plane.
z1 - The z coordinate of the first point in the plane.
x2 - The x coordinate of the second point in the plane.
y2 - The y coordinate of the second point in the plane.
z2 - The z coordinate of the second point in the plane.
x3 - The x coordinate of the third point in the plane.
y3 - The y coordinate of the third point in the plane.
z3 - The z coordinate of the third point in the plane.
See Also:
calcEquations(double, double, double, double, double, double, double, double, double)
Method Detail

calcNormalVector

protected void calcNormalVector(Mesh.Polygon polygon)
Initializes the normalVector variable.
Parameters:
polygon - the polygon to calculate the normal vector from

calcEquations

protected void calcEquations(double x1,
                             double y1,
                             double z1,
                             double x2,
                             double y2,
                             double z2,
                             double x3,
                             double y3,
                             double z3)
Calculate the values of A,B,C,D of the plane equation.
Parameters:
x1 - The x coordinate of the first point in the plane.
y1 - The y coordinate of the first point in the plane.
z1 - The z coordinate of the first point in the plane.
x2 - The x coordinate of the second point in the plane.
y2 - The y coordinate of the second point in the plane.
z2 - The z coordinate of the second point in the plane.
x3 - The x coordinate of the third point in the plane.
y3 - The y coordinate of the third point in the plane.
z3 - The z coordinate of the third point in the plane.
See Also:
A, B, C, D

evaluate

public double evaluate(Point3D pt)
Evaluates a point to the plane equation.
Parameters:
point - the point to evaluate.
Returns:
  • = 0 if the point is on the plane,
  • < 0 if the point is in the back of the plane,
  • > 0 if the point is in the front of the plane.
See Also:
evaluate(double x,double y,double z)

evaluate

public double evaluate(double x,
                       double y,
                       double z)
Evaluates a point to the plane equation.
Parameters:
x - x-value of the point to evaluate.
y - y-value of the point to evaluate.
z - z-value of the point to evaluate.
Returns:
  • = 0 if the point is on the plane,
  • < 0 if the point is in the back of the plane,
  • > 0 if the point is in the front of the plane.
See Also:
evaluate(Point3D pt)

calcZ

public double calcZ(double x,
                    double y)
Returns a Z value on the plane given the X and Y values.
Returns:
the Z value of the point at the plane.

getNormalVector

public Vector3D getNormalVector()
Returns the normal vector.