Class Pnt

  • All Implemented Interfaces:
    Serializable


    public class Pnt
    extends Object
    implements Serializable
    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.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors

      Constructor and Description
      Pnt(double... coords)
      Constructor.
    • Method Summary

      Modifier and Type Method and Description
      Pnt add(Pnt p)
      Add.
      double angle(Pnt p)
      Angle (in radians) between two Pnts (treated as vectors).
      Pnt 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 dimCheck(Pnt p)
      Check that dimensions match.
      int dimension()
       
      double dot(Pnt p)
      Dot product.
      boolean equals(Object other)
       
      Pnt 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.
      Pnt isOn(Pnt[] simplex)
      Test if this Pnt is on a simplex.
      Pnt isOutside(Pnt[] simplex)
      Test if this Pnt is outside of simplex.
      double magnitude()
      Magnitude (as a vector).
      int[] relation(Pnt[] simplex)
      Relation between this Pnt and a simplex (represented as an array of Pnts).
      Pnt subtract(Pnt p)
      Subtract.
      String toString()
       
      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.
    • Constructor Detail

      • Pnt

        public Pnt(double... coords)
        Constructor.
        Parameters:
        coords - the coordinates
    • Method Detail

      • toString

        public String toString()
      • equals

        public boolean equals(Object other)
      • hashCode

        public int hashCode()
      • coord

        public double coord(int i)
        Parameters:
        i - the index of the coordinate.
        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 simplex
        Throws:
        IllegalArgumentException - if the simplex is degenerate
      • isOutside

        public Pnt isOutside(Pnt[] simplex)
        Test if this Pnt is outside of simplex.
        Parameters:
        simplex - the simplex (an array of Pnts)
        Returns:
        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