org.geotools.math
Class Plane

Object
  extended by Plane
All Implemented Interfaces:
Serializable, Cloneable

public class Plane
extends Object
implements Cloneable, Serializable

Equation of a plane in a three-dimensional space (x,y,z). The plane equation is expressed by c, cx and cy coefficients as below:

z(x,y) = c + cx*x + cy*y
Those coefficients can be set directly, or computed by a linear regression of this plane through a set of three-dimensional points.

Since:
2.0
Author:
Martin Desruisseaux (PMO, IRD), Howard Freeland, for algorithmic inspiration
See Also:
Serialized Form
Module:
modules/library/metadata (gt-metadata.jar)

Field Summary
 double c
          The c coefficient for this plane.
 double cx
          The cx coefficient for this plane.
 double cy
          The cy coefficient for this plane.
 
Constructor Summary
Plane()
          Construct a new plane.
 
Method Summary
 Plane clone()
          Returns a clone of this plane.
 boolean equals(Object object)
          Compares this plane with the specified object for equality.
 int hashCode()
          Returns a hash code value for this plane.
 void setPlane(double[] x, double[] y, double[] z)
          Computes the plane's coefficients from a set of points.
 void setPlane(Point3d P1, Point3d P2, Point3d P3)
          Computes the plane's coefficients from the specified points.
 String toString()
          Returns a string representation of this plane.
 double x(double y, double z)
          Computes the x value for the specified (y,z) point.
 double y(double x, double z)
          Computes the y value for the specified (x,z) point.
 double z(double x, double y)
          Computes the z value for the specified (x,y) point.
 
Methods inherited from class Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

c

public double c
The c coefficient for this plane. This coefficient appears in the place equation c+cx*x+cy*y.


cx

public double cx
The cx coefficient for this plane. This coefficient appears in the place equation c+cx*x+cy*y.


cy

public double cy
The cy coefficient for this plane. This coefficient appears in the place equation c+cx*x+cy*y.

Constructor Detail

Plane

public Plane()
Construct a new plane. All coefficients are set to 0.

Method Detail

z

public final double z(double x,
                      double y)
Computes the z value for the specified (x,y) point. The z value is computed using the following equation:
z(x,y) = c + cx*x + cy*y

Parameters:
x - The x value.
y - The y value.
Returns:
The z value.

y

public final double y(double x,
                      double z)
Computes the y value for the specified (x,z) point. The y value is computed using the following equation:
y(x,z) = (z - (c+cx*x)) / cy

Parameters:
x - The x value.
z - The y value.
Returns:
The y value.

x

public final double x(double y,
                      double z)
Computes the x value for the specified (y,z) point. The x value is computed using the following equation:
x(y,z) = (z - (c+cy*y)) / cx

Parameters:
y - The x value.
z - The y value.
Returns:
The x value.

setPlane

public void setPlane(Point3d P1,
                     Point3d P2,
                     Point3d P3)
              throws ArithmeticException
Computes the plane's coefficients from the specified points. Three points are enough for determining exactly the plan, providing that the points are not colinear.

Throws:
ArithmeticException - If the three points are colinear.

setPlane

public void setPlane(double[] x,
                     double[] y,
                     double[] z)
              throws MismatchedSizeException
Computes the plane's coefficients from a set of points. This method use a linear regression in the least-square sense. Result is undertermined if all points are colinear.

Parameters:
x - vector of x coordinates
y - vector of y coordinates
z - vector of z values
Throws:
MismatchedSizeException - if x, y and z don't have the same length.

toString

public String toString()
Returns a string representation of this plane. The string will contains the plane's equation, as below:
z(x,y) = c + cx*x + cy*y

Overrides:
toString in class Object

equals

public boolean equals(Object object)
Compares this plane with the specified object for equality.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code value for this plane.

Overrides:
hashCode in class Object

clone

public Plane clone()
Returns a clone of this plane.

Overrides:
clone in class Object


Copyright © 1996-2009 Geotools. All Rights Reserved.