Package toxi.geom.mesh2d
Class DelaunayVertex
java.lang.Object
toxi.geom.mesh2d.DelaunayVertex
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. Modified Novemeber 2007. Minor clean up.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdd.double
Angle (in radians) between two Pnts (treated as vectors).bisector
(DelaunayVertex point) Perpendicular bisector of two Pnts.static DelaunayVertex
circumcenter
(DelaunayVertex[] simplex) Circumcenter of a simplex.static double
content
(DelaunayVertex[] simplex) Determine the signed content (i.e., area or volume, etc.) of a simplex.double
coord
(int i) static DelaunayVertex
cross
(DelaunayVertex[] matrix) Compute generalized cross-product of the rows of a matrix.static double
determinant
(DelaunayVertex[] matrix) Compute the determinant of a matrix (array of Pnts).int
Check that dimensions match.int
double
Dot product.boolean
extend
(double... coords) Create a new DelaunayVertex by adding additional coordinates to this DelaunayVertex.int
hashCode()
boolean
isInside
(DelaunayVertex[] simplex) Test if this DelaunayVertex is inside a simplex.isOn
(DelaunayVertex[] simplex) Test if this DelaunayVertex is on a simplex.isOutside
(DelaunayVertex[] simplex) Test if this DelaunayVertex is outside of simplex.double
Magnitude (as a vector).int[]
relation
(DelaunayVertex[] simplex) Relation between this DelaunayVertex and a simplex (represented as an array of Pnts).Subtract.toString()
static String
toString
(DelaunayVertex[] matrix) Create a String for a matrix.toVec2D()
int
vsCircumcircle
(DelaunayVertex[] simplex) Test relation between this DelaunayVertex and circumcircle of a simplex.
-
Constructor Details
-
DelaunayVertex
public DelaunayVertex(double... coords) Constructor.- Parameters:
coords
- the coordinates
-
-
Method Details
-
circumcenter
Circumcenter of a simplex.- Parameters:
simplex
- the simplex (as an array of Pnts)- Returns:
- the circumcenter (a DelaunayVertex) of simplex
-
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
-
cross
Compute generalized cross-product of the rows of a matrix. The result is a DelaunayVertex 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 DelaunayVertex dimension)- Returns:
- a DelaunayVertex perpendicular to each row DelaunayVertex
- Throws:
IllegalArgumentException
- if matrix is wrong shape
-
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
-
toString
Create a String for a matrix.- Parameters:
matrix
- the matrix (an array of Pnts)- Returns:
- a String represenation of the matrix
-
add
Add.- Parameters:
p
- the other DelaunayVertex- Returns:
- a new DelaunayVertex = this + p
-
angle
Angle (in radians) between two Pnts (treated as vectors).- Parameters:
p
- the other DelaunayVertex- 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 DelaunayVertex 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
-
coord
public double coord(int i) - Returns:
- the specified coordinate of this DelaunayVertex
- Throws:
ArrayIndexOutOfBoundsException
- for bad coordinate
-
dimCheck
Check that dimensions match.- Parameters:
p
- the DelaunayVertex to check (against this DelaunayVertex)- Returns:
- the dimension of the Pnts
- Throws:
IllegalArgumentException
- if dimension fail to match
-
dimension
public int dimension()- Returns:
- this DelaunayVertex's dimension.
-
dot
Dot product.- Parameters:
p
- the other DelaunayVertex- Returns:
- dot product of this DelaunayVertex and p
-
equals
-
extend
Create a new DelaunayVertex by adding additional coordinates to this DelaunayVertex.- Parameters:
coords
- the new coordinates (added on the right end)- Returns:
- a new DelaunayVertex with the additional coordinates
-
hashCode
public int hashCode() -
isInside
Test if this DelaunayVertex is inside a simplex.- Parameters:
simplex
- the simplex (an arary of Pnts)- Returns:
- true iff this DelaunayVertex is inside simplex.
-
isOn
Test if this DelaunayVertex is on a simplex.- Parameters:
simplex
- the simplex (an array of Pnts)- Returns:
- the simplex DelaunayVertex that "witnesses" on-ness (or null if not on)
-
isOutside
Test if this DelaunayVertex is outside of simplex.- Parameters:
simplex
- the simplex (an array of Pnts)- Returns:
- simplex DelaunayVertex that "witnesses" outsideness (or null if not outside)
-
magnitude
public double magnitude()Magnitude (as a vector).- Returns:
- the Euclidean length of this vector
-
relation
Relation between this DelaunayVertex 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 DelaunayVertex.-1 means DelaunayVertex is on same side of facet 0 means DelaunayVertex is on the facet +1 means DelaunayVertex is on opposite side of facet
- Parameters:
simplex
- an array of Pnts representing a simplex- Returns:
- an array of signs showing relation between this DelaunayVertex and simplex
- Throws:
IllegalArgumentExcpetion
- if the simplex is degenerate
-
subtract
Subtract.- Parameters:
p
- the other DelaunayVertex- Returns:
- a new DelaunayVertex = this - p
-
toString
-
toVec2D
-
vsCircumcircle
Test relation between this DelaunayVertex 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
-