toxi.geom.mesh2d
Class DelaunayVertex

java.lang.Object
  extended by toxi.geom.mesh2d.DelaunayVertex

public class DelaunayVertex
extends java.lang.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.


Constructor Summary
DelaunayVertex(double... coords)
          Constructor.
 
Method Summary
 DelaunayVertex add(DelaunayVertex p)
          Add.
 double angle(DelaunayVertex p)
          Angle (in radians) between two Pnts (treated as vectors).
 DelaunayVertex 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 dimCheck(DelaunayVertex p)
          Check that dimensions match.
 int dimension()
           
 double dot(DelaunayVertex p)
          Dot product.
 boolean equals(java.lang.Object other)
           
 DelaunayVertex 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.
 DelaunayVertex isOn(DelaunayVertex[] simplex)
          Test if this DelaunayVertex is on a simplex.
 DelaunayVertex isOutside(DelaunayVertex[] simplex)
          Test if this DelaunayVertex is outside of simplex.
 double magnitude()
          Magnitude (as a vector).
 int[] relation(DelaunayVertex[] simplex)
          Relation between this DelaunayVertex and a simplex (represented as an array of Pnts).
 DelaunayVertex subtract(DelaunayVertex p)
          Subtract.
 java.lang.String toString()
           
static java.lang.String toString(DelaunayVertex[] matrix)
          Create a String for a matrix.
 Vec2D toVec2D()
           
 int vsCircumcircle(DelaunayVertex[] simplex)
          Test relation between this DelaunayVertex and circumcircle of a simplex.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DelaunayVertex

public DelaunayVertex(double... coords)
Constructor.

Parameters:
coords - the coordinates
Method Detail

circumcenter

public static DelaunayVertex circumcenter(DelaunayVertex[] simplex)
Circumcenter of a simplex.

Parameters:
simplex - the simplex (as an array of Pnts)
Returns:
the circumcenter (a DelaunayVertex) of simplex

content

public static double content(DelaunayVertex[] 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

cross

public static DelaunayVertex cross(DelaunayVertex[] matrix)
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:
java.lang.IllegalArgumentException - if matrix is wrong shape

determinant

public static double determinant(DelaunayVertex[] 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:
java.lang.IllegalArgumentException - if dimensions are wrong

toString

public static java.lang.String toString(DelaunayVertex[] matrix)
Create a String for a matrix.

Parameters:
matrix - the matrix (an array of Pnts)
Returns:
a String represenation of the matrix

add

public DelaunayVertex add(DelaunayVertex p)
Add.

Parameters:
p - the other DelaunayVertex
Returns:
a new DelaunayVertex = this + p

angle

public double angle(DelaunayVertex p)
Angle (in radians) between two Pnts (treated as vectors).

Parameters:
p - the other DelaunayVertex
Returns:
the angle (in radians) between the two Pnts

bisector

public DelaunayVertex bisector(DelaunayVertex point)
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:
java.lang.ArrayIndexOutOfBoundsException - for bad coordinate

dimCheck

public int dimCheck(DelaunayVertex p)
Check that dimensions match.

Parameters:
p - the DelaunayVertex to check (against this DelaunayVertex)
Returns:
the dimension of the Pnts
Throws:
java.lang.IllegalArgumentException - if dimension fail to match

dimension

public int dimension()
Returns:
this DelaunayVertex's dimension.

dot

public double dot(DelaunayVertex p)
Dot product.

Parameters:
p - the other DelaunayVertex
Returns:
dot product of this DelaunayVertex and p

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

extend

public DelaunayVertex extend(double... coords)
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()
Overrides:
hashCode in class java.lang.Object

isInside

public boolean isInside(DelaunayVertex[] simplex)
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

public DelaunayVertex isOn(DelaunayVertex[] simplex)
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

public DelaunayVertex isOutside(DelaunayVertex[] simplex)
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

public int[] relation(DelaunayVertex[] simplex)
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

public DelaunayVertex subtract(DelaunayVertex p)
Subtract.

Parameters:
p - the other DelaunayVertex
Returns:
a new DelaunayVertex = this - p

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toVec2D

public Vec2D toVec2D()

vsCircumcircle

public int vsCircumcircle(DelaunayVertex[] simplex)
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