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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Pntadd(Pnt p)Add.doubleangle(Pnt p)Angle (in radians) between two Pnts (treated as vectors).Pntbisector(Pnt point)Perpendicular bisector of two Pnts.static Pntcircumcenter(Pnt[] simplex)Circumcenter of a simplex.static doublecontent(Pnt[] simplex)Determine the signed content (i.e., area or volume, etc.) of a simplex.doublecoord(int i)static Pntcross(Pnt[] matrix)Compute generalized cross-product of the rows of a matrix.static doubledeterminant(Pnt[] matrix)Compute the determinant of a matrix (array of Pnts).intdimCheck(Pnt p)Check that dimensions match.intdimension()doubledot(Pnt p)Dot product.booleanequals(Object other)Equality.Pntextend(double[] coords)Create a new Pnt by adding additional coordinates to this Pnt.inthashCode()HashCode.booleanisInside(Pnt[] simplex)Test if this Pnt is inside a simplex.PntisOn(Pnt[] simplex)Test if this Pnt is on a simplex.PntisOutside(Pnt[] simplex)Test if this Pnt is outside of simplex.doublemagnitude()Magnitude (as a vector).static voidmain(String[] args)Main program (used for testing).int[]relation(Pnt[] simplex)Relation between this Pnt and a simplex (represented as an array of Pnts).Pntsubtract(Pnt p)Subtract.StringtoString()Create a String for this Pnt.static StringtoString(Pnt[] matrix)Create a String for a matrix.intvsCircumcircle(Pnt[] simplex)Test relation between this Pnt and circumcircle of a simplex.
-
-
-
Constructor Detail
-
Pnt
public Pnt(double[] coords)
Constructor.- Parameters:
coords- the coordinates
-
Pnt
public Pnt(double coordA, double coordB)Constructor.- Parameters:
coordA- first ordinate of the pointcoordB- second ordinate of the point
-
Pnt
public Pnt(double coordA, double coordB, double coordC)Constructor.- Parameters:
coordA- first ordinate of the pointcoordB- second ordinate of the pointcoordC- third ordinate of the point
-
-
Method Detail
-
toString
public String toString()
Create a String for this Pnt.
-
equals
public boolean equals(Object other)
Equality.
-
hashCode
public int hashCode()
HashCode.
-
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
-
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).
-
-