Package org.web3d.util.spatial
Class Triangle
java.lang.Object
org.web3d.util.spatial.Triangle
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
calcBounds
(double[] min, double[] max) Calculate a bounding box for the triangle.void
calcBounds
(float[] min, float[] max) Calculate a bounding box for the triangle.int
Compares this object with the specified object for order.int
Compares this object with the specified object for order.boolean
Compare this object for equality to the given object.boolean
Compares this object with the specified object to check for equivalence.float
getArea()
Get the area of this triangle.double
Get the largest side.double
Calc the ratio between the smallest side to largest.Triangle[]
splitTriangle
(int nextID) Split a triangle into pieces.
-
Field Details
-
coords
public float[] coordsThe coordinates -
id
public int idThe ID used for uniqueness
-
-
Constructor Details
-
Triangle
public Triangle(float[] coords, int id) Constructor.- Parameters:
coords
- The 9 coords making up the triangleid
-
-
-
Method Details
-
getArea
public float getArea()Get the area of this triangle. Uses Heron's Formula- Returns:
- The area
-
getLargestSide
public double getLargestSide()Get the largest side.- Returns:
-
getSideRatio
public double getSideRatio()Calc the ratio between the smallest side to largest.- Returns:
-
splitTriangle
Split a triangle into pieces. Uses the mid-point of two longest edges to create 3 triangles.- Parameters:
nextID
- The next triangle ID to insure uniqueness of new id's. Increment total by 2 as first will be reused.- Returns:
-
equals
-
equals
Compares this object with the specified object to check for equivalence.- Parameters:
ta
- The geometry instance to be compared- Returns:
- true if the objects represent identical values
-
compareTo
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Parameters:
o
- The object to be compared- Returns:
- -1, 0 or 1 depending on order
- Throws:
ClassCastException
- The specified object's type prevents it from being compared to this Object
-
compareTo
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Parameters:
ta
- The argument instance to be compared- Returns:
- -1, 0 or 1 depending on order
-
calcBounds
public void calcBounds(float[] min, float[] max) Calculate a bounding box for the triangle.- Parameters:
min
- The array to fill in the min boundsmax
- The array to fill in the max bounds
-
calcBounds
public void calcBounds(double[] min, double[] max) Calculate a bounding box for the triangle.- Parameters:
min
- The array to fill in the min boundsmax
- The array to fill in the max bounds
-