Class Plane

  • All Implemented Interfaces:
    Serializable, Cloneable, 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
    • Field Summary

      Fields 
      Modifier and Type Field Description
      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

      Constructors 
      Constructor Description
      Plane()
      Construct a new plane.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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[][] points)
      Computes the plane's coefficients from the specified points.
      void setPlane​(double[] x, double[] y, double[] z)
      Computes the plane's coefficients from a set of 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​(double[][] points)
                      throws ArithmeticException
        Computes the plane's coefficients from the specified points. Three points are enough for determining exactly the plane, providing that the points are not colinear. This method allows points to be provided in Z,Y,Z order:
         double[] P1 = new double[]{ a.getX(), a.getY(), a.getZ() );
         double[] P2 = new double[]{ b.getX(), b.getY(), b.getZ() );
         double[] P3 = new double[]{ c.getX(), c.getY(), c.getZ() );
         plane.setPlane( new double[][]{ P1, P2, P3 } );
        Parameters:
        points - Array of three points
        Throws:
        ArithmeticException - If the three points are colinear.
      • setPlane

        public void setPlane​(double[] x,
                             double[] y,
                             double[] z)
                      throws IllegalArgumentException
        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. This method allows points to be provided as a series of X,Y and Z arrays:
         double[] X = new double[]{ a.getX(), b.getX(), c.getX() );
         double[] Y = new double[]{ a.getX(), b.getX(), c.getX() );
         double[] Z = new double[]{ a.getZ(), b.getZ(), c.getZ() );
         plane.setPlane( X, Y, Z  );
        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.
        IllegalArgumentException
      • 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.
        Specified by:
        clone in interface Cloneable
        Overrides:
        clone in class Object
        Returns:
        A copy of this object.
        See Also:
        Object.clone()