Class Pnt

java.lang.Object
org.openjump.core.graph.delauneySimplexInsert.Pnt

public class Pnt extends Object
Points in Euclidean space, implemented as double[]. Includes simple geometric operations. Uses matrices; a matrix is represented as an array of Pnts. Uses simplices; a simplex is represented as an array of Pnts.
Author:
Paul Chew Created July 2005. Derived from an earlier, messier version.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Pnt(double[] coords)
    Constructor.
    Pnt(double coordA, double coordB)
    Constructor.
    Pnt(double coordA, double coordB, double coordC)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(Pnt p)
    Add.
    double
    Angle (in radians) between two Pnts (treated as vectors).
    bisector(Pnt point)
    Perpendicular bisector of two Pnts.
    static Pnt
    circumcenter(Pnt[] simplex)
    Circumcenter of a simplex.
    static double
    content(Pnt[] simplex)
    Determine the signed content (i.e., area or volume, etc.) of a simplex.
    double
    coord(int i)
     
    static Pnt
    cross(Pnt[] matrix)
    Compute generalized cross-product of the rows of a matrix.
    static double
    determinant(Pnt[] matrix)
    Compute the determinant of a matrix (array of Pnts).
    int
    Check that dimensions match.
    int
     
    double
    dot(Pnt p)
    Dot product.
    boolean
    equals(Object other)
    Equality.
    extend(double[] coords)
    Create a new Pnt by adding additional coordinates to this Pnt.
    int
    HashCode.
    boolean
    isInside(Pnt[] simplex)
    Test if this Pnt is inside a simplex.
    isOn(Pnt[] simplex)
    Test if this Pnt is on a simplex.
    isOutside(Pnt[] simplex)
    Test if this Pnt is outside of simplex.
    double
    Magnitude (as a vector).
    static void
    main(String[] args)
    Main program (used for testing).
    int[]
    relation(Pnt[] simplex)
    Relation between this Pnt and a simplex (represented as an array of Pnts).
    Subtract.
    Create a String for this Pnt.
    static String
    toString(Pnt[] matrix)
    Create a String for a matrix.
    int
    vsCircumcircle(Pnt[] simplex)
    Test relation between this Pnt and circumcircle of a simplex.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Pnt

      public Pnt(double[] coords)
      Constructor.
      Parameters:
      coords - the coordinates
    • Pnt

      public Pnt(double coordA, double coordB)
      Constructor.
      Parameters:
      coordA - first ordinate of the point
      coordB - second ordinate of the point
    • Pnt

      public Pnt(double coordA, double coordB, double coordC)
      Constructor.
      Parameters:
      coordA - first ordinate of the point
      coordB - second ordinate of the point
      coordC - third ordinate of the point
  • Method Details

    • toString

      public String toString()
      Create a String for this Pnt.
      Overrides:
      toString in class Object
      Returns:
      a String representation of this Pnt.
    • equals

      public boolean equals(Object other)
      Equality.
      Overrides:
      equals in class Object
      Parameters:
      other - the other Object to compare to
      Returns:
      true iff the Pnts have the same coordinates
    • hashCode

      public int hashCode()
      HashCode.
      Overrides:
      hashCode in class Object
      Returns:
      the hashCode for this Pnt
    • coord

      public double coord(int i)
      Returns:
      the specified coordinate of this Pnt
      Throws:
      ArrayIndexOutOfBoundsException - for bad coordinate
    • dimension

      public int dimension()
      Returns:
      this Pnt's dimension.
    • dimCheck

      public int dimCheck(Pnt p)
      Check that dimensions match.
      Parameters:
      p - the Pnt to check (against this Pnt)
      Returns:
      the dimension of the Pnts
      Throws:
      IllegalArgumentException - if dimension fail to match
    • extend

      public Pnt extend(double[] coords)
      Create a new Pnt by adding additional coordinates to this Pnt.
      Parameters:
      coords - the new coordinates (added on the right end)
      Returns:
      a new Pnt with the additional coordinates
    • dot

      public double dot(Pnt p)
      Dot product.
      Parameters:
      p - the other Pnt
      Returns:
      dot product of this Pnt and p
    • magnitude

      public double magnitude()
      Magnitude (as a vector).
      Returns:
      the Euclidean length of this vector
    • subtract

      public Pnt subtract(Pnt p)
      Subtract.
      Parameters:
      p - the other Pnt
      Returns:
      a new Pnt = this - p
    • add

      public Pnt add(Pnt p)
      Add.
      Parameters:
      p - the other Pnt
      Returns:
      a new Pnt = this + p
    • angle

      public double angle(Pnt p)
      Angle (in radians) between two Pnts (treated as vectors).
      Parameters:
      p - the other Pnt
      Returns:
      the angle (in radians) between the two Pnts
    • bisector

      public Pnt bisector(Pnt point)
      Perpendicular bisector of two Pnts. Works in any dimension. The coefficients are returned as a Pnt of one higher dimension (e.g., (A,B,C,D) for an equation of the form Ax + By + Cz + D = 0).
      Parameters:
      point - the other point
      Returns:
      the coefficients of the perpendicular bisector
    • toString

      public static String toString(Pnt[] matrix)
      Create a String for a matrix.
      Parameters:
      matrix - the matrix (an array of Pnts)
      Returns:
      a String represenation of the matrix
    • determinant

      public static double determinant(Pnt[] matrix)
      Compute the determinant of a matrix (array of Pnts). This is not an efficient implementation, but should be adequate for low dimension.
      Parameters:
      matrix - the matrix as an array of Pnts
      Returns:
      the determinnant of the input matrix
      Throws:
      IllegalArgumentException - if dimensions are wrong
    • cross

      public static Pnt cross(Pnt[] matrix)
      Compute generalized cross-product of the rows of a matrix. The result is a Pnt perpendicular (as a vector) to each row of the matrix. This is not an efficient implementation, but should be adequate for low dimension.
      Parameters:
      matrix - the matrix of Pnts (one less row than the Pnt dimension)
      Returns:
      a Pnt perpendicular to each row Pnt
      Throws:
      IllegalArgumentException - if matrix is wrong shape
    • content

      public static double content(Pnt[] simplex)
      Determine the signed content (i.e., area or volume, etc.) of a simplex.
      Parameters:
      simplex - the simplex (as an array of Pnts)
      Returns:
      the signed content of the simplex
    • relation

      public int[] relation(Pnt[] simplex)
      Relation between this Pnt and a simplex (represented as an array of Pnts). Result is an array of signs, one for each vertex of the simplex, indicating the relation between the vertex, the vertex's opposite facet, and this Pnt.
        -1 means Pnt is on same side of facet
         0 means Pnt is on the facet
        +1 means Pnt is on opposite side of facet
      Parameters:
      simplex - an array of Pnts representing a simplex
      Returns:
      an array of signs showing relation between this Pnt and the simplex
    • isOutside

      public Pnt isOutside(Pnt[] simplex)
      Test if this Pnt is outside of simplex.
      Parameters:
      simplex - the simplex (an array of Pnts)
      Returns:
      the simplex Pnt that "witnesses" outsideness (or null if not outside)
    • isOn

      public Pnt isOn(Pnt[] simplex)
      Test if this Pnt is on a simplex.
      Parameters:
      simplex - the simplex (an array of Pnts)
      Returns:
      the simplex Pnt that "witnesses" on-ness (or null if not on)
    • isInside

      public boolean isInside(Pnt[] simplex)
      Test if this Pnt is inside a simplex.
      Parameters:
      simplex - the simplex (an arary of Pnts)
      Returns:
      true iff this Pnt is inside simplex.
    • vsCircumcircle

      public int vsCircumcircle(Pnt[] simplex)
      Test relation between this Pnt and circumcircle of a simplex.
      Parameters:
      simplex - the simplex (as an array of Pnts)
      Returns:
      -1, 0, or +1 for inside, on, or outside of circumcircle
    • circumcenter

      public static Pnt circumcenter(Pnt[] simplex)
      Circumcenter of a simplex.
      Parameters:
      simplex - the simplex (as an array of Pnts)
      Returns:
      the circumcenter (a Pnt) of simplex
    • main

      public static void main(String[] args)
      Main program (used for testing).