Class DelaunayVertex

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

public class DelaunayVertex 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. Modified Novemeber 2007. Minor clean up.
  • Constructor Details

    • DelaunayVertex

      public DelaunayVertex(double... coords)
      Constructor.
      Parameters:
      coords - the coordinates
  • Method Details

    • 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:
      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:
      IllegalArgumentException - if dimensions are wrong
    • toString

      public static 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

      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:
      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:
      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(Object other)
      Overrides:
      equals in class 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 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 String toString()
      Overrides:
      toString in class 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