org.geotoolkit.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:
1.0
Version:
3.09
Author:
Martin Desruisseaux (MPO, IRD), Howard Freeland (MPO, for algorithmic inspiration)
See Also:
Serialized Form
Module:
utility/geotk-utility (download)    View source code for this class

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.
 double fit(double[] x, double[] y, double[] z)
          Computes the plane's coefficients from a set of points.
 double fit(float[] x, float[] y, float[] z)
          Computes the plane's coefficients from a set of points.
 double fit(Vector x, Vector y, Vector z)
          Computes the plane's coefficients from a set of points.
 int hashCode()
          Returns a hash code value for this plane.
 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.

Parameters:
P1 - The first point.
P2 - The second point.
P3 - The third point.
Throws:
ArithmeticException - If the three points are colinear.

fit

public double fit(double[] x,
                  double[] y,
                  double[] z)
           throws MismatchedSizeException
Computes the plane's coefficients from a set of points. This convenience method wraps the given arrays in Vector objects and delegates to fit(Vector, Vector, Vector).

Parameters:
x - array of x coordinates
y - array of y coordinates
z - array of z values
Returns:
An estimation of the Pearson correlation coefficient.
Throws:
MismatchedSizeException - if x, y and z don't have the same length.

fit

public double fit(float[] x,
                  float[] y,
                  float[] z)
           throws MismatchedSizeException
Computes the plane's coefficients from a set of points. This convenience method wraps the given arrays in Vector objects and delegates to fit(Vector, Vector, Vector).

Parameters:
x - array of x coordinates
y - array of y coordinates
z - array of z values
Returns:
An estimation of the Pearson correlation coefficient.
Throws:
MismatchedSizeException - if x, y and z don't have the same length.
Since:
3.09

fit

public double fit(Vector x,
                  Vector y,
                  Vector z)
           throws MismatchedSizeException
Computes the plane's coefficients from a set of points. This method uses 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
Returns:
An estimation of the Pearson correlation coefficient.
Throws:
MismatchedSizeException - if x, y and z don't have the same length.
Since:
3.09

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
Parameters:
object - The object to compare with this plane for equality.
Returns:
true if both objects are equal.

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
Returns:
A copy of this object.
See Also:
Object.clone()


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.