Class Pnt
java.lang.Object
org.openjump.core.graph.delauneySimplexInsert.Pnt
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 -
Method Summary
Modifier and TypeMethodDescriptionAdd.doubleAngle (in radians) between two Pnts (treated as vectors).Perpendicular bisector of two Pnts.static Pntcircumcenter(Pnt[] simplex) Circumcenter of a simplex.static doubleDetermine the signed content (i.e., area or volume, etc.) of a simplex.doublecoord(int i) static PntCompute generalized cross-product of the rows of a matrix.static doubledeterminant(Pnt[] matrix) Compute the determinant of a matrix (array of Pnts).intCheck that dimensions match.intdoubleDot product.booleanEquality.extend(double[] coords) Create a new Pnt by adding additional coordinates to this Pnt.inthashCode()HashCode.booleanTest if this Pnt is inside a simplex.Test if this Pnt is on a simplex.Test if this Pnt is outside of simplex.doubleMagnitude (as a vector).static voidMain program (used for testing).int[]Relation between this Pnt and a simplex (represented as an array of Pnts).Subtract.toString()Create a String for this Pnt.static StringCreate a String for a matrix.intvsCircumcircle(Pnt[] simplex) Test relation between this Pnt and circumcircle of a simplex.
-
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 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 Details
-
toString
-
equals
-
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
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
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
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
-
add
-
angle
Angle (in radians) between two Pnts (treated as vectors).- Parameters:
p- the other Pnt- Returns:
- the angle (in radians) between the two Pnts
-
bisector
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
-
determinant
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
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
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
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
-
isOn
-
isInside
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
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
-
main
Main program (used for testing).
-