Package geomss.geom
Class Triangle
- java.lang.Object
-
- geomss.geom.AbstractGeomElement<GeomTriangle>
-
- geomss.geom.GeomTriangle
-
- geomss.geom.Triangle
-
- All Implemented Interfaces:
GeomElement<GeomTriangle>
,PointGeometry<GeomTriangle>
,Transformable<GeomTriangle>
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable
,javolution.lang.Immutable
,javolution.lang.Reusable
,javolution.lang.ValueType
,javolution.xml.XMLSerializable
public final class Triangle extends GeomTriangle implements javolution.lang.ValueType
A concrete triangle in n-dimensional space. A triangle is represented by exactly three vertex points arranged in a counter-clockwise direction (or winding) when viewed from the "outside" (the direction the normal vector points).Modified by: Joseph A. Huwaldt
- Version:
- November 28, 2015
- Author:
- Joseph A. Huwaldt, Date: August 26, 2015
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class geomss.geom.AbstractGeomElement
RESOURCES
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Triangle
copy()
Returns a copy of this Triangle instance allocated by the calling thread (possibly on the stack).Triangle
copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).boolean
equals(java.lang.Object obj)
Compares this Triangle against the specified object for strict equality.Parameter<javax.measure.quantity.Area>
getArea()
Return the surface area of one side of this triangle.Point
getBoundsMax()
Return the coordinate point representing the maximum bounding box corner (e.g.: max X, max Y, max Z).Point
getBoundsMin()
Return the coordinate point representing the minimum bounding box corner of this geometry element (e.g.: min X, min Y, min Z).Vector<javax.measure.quantity.Dimensionless>
getNormal()
Return the surface unit normal vector for this triangle.Point
getP1()
Return the first vertex in this triangle.Point
getP2()
Return the second vertex in this triangle.Point
getP3()
Return the third and last vertex in this triangle.TriangleTrans
getTransformed(GTransform transform)
Returns transformed version of this element.int
hashCode()
Returns the hash code for this parameter.static void
recycle(Triangle instance)
Recycles aTriangle
instance immediately (on the stack when executing in aStackContext
).Triangle
reverse()
Return a new triangle that is identical to this one, but with the order of the points (and the surface normal direction) reversed.Triangle
to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit)
Returns the equivalent to this element but stated in the specified unit.Triangle
toDimension(int newDim)
Return a copy of this Triangle converted to the specified number of physical dimensions.static Triangle
valueOf(GeomPoint[] points)
Returns aTriangle
instance with the specified corner vertices in counter-clockwise order/winding when looking down the surface normal vector.static Triangle
valueOf(GeomPoint p1, GeomPoint p2, GeomPoint p3)
Returns aTriangle
instance with the specified corner vertices in counter-clockwise order/winding when looking down the surface normal vector.static Triangle
valueOf(java.util.List<? extends GeomPoint> points)
Returns aTriangle
instance with the specified corner vertices in counter-clockwise order/winding when looking down the surface normal vector.-
Methods inherited from class geomss.geom.GeomTriangle
getAll, getLimitPoint, getNumberOfPoints, getParDimension, getPhyDimension, getPoints, getPoints, getUnit, isDegenerate, isValid, reset, size, toText
-
Methods inherited from class geomss.geom.AbstractGeomElement
addChangeListener, clone, compareTo, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName, toString
-
Methods inherited from interface geomss.geom.GeomElement
addChangeListener, getAllUserData, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName
-
-
-
-
Method Detail
-
valueOf
public static Triangle valueOf(GeomPoint p1, GeomPoint p2, GeomPoint p3)
Returns aTriangle
instance with the specified corner vertices in counter-clockwise order/winding when looking down the surface normal vector. The units of the triangle will be the units of the start point.- Parameters:
p1
- The start (beginning) of the triangle. May not be null.p2
- The second point in the triangle. May not be null.p3
- The third and last point in the triangle. May not be null.- Returns:
- A
Triangle
instance defined by the input points.
-
valueOf
public static Triangle valueOf(java.util.List<? extends GeomPoint> points)
Returns aTriangle
instance with the specified corner vertices in counter-clockwise order/winding when looking down the surface normal vector. The units of the triangle will be the units of the start point.- Parameters:
points
- A list of 3 points that form the triangle. May not be null.- Returns:
- A
Triangle
instance defined by the input points.
-
valueOf
public static Triangle valueOf(GeomPoint[] points)
Returns aTriangle
instance with the specified corner vertices in counter-clockwise order/winding when looking down the surface normal vector. The units of the triangle will be the units of the start point.- Parameters:
points
- An array of 3 points that form the triangle. May not be null.- Returns:
- A
Triangle
instance defined by the input points.
-
recycle
public static void recycle(Triangle instance)
Recycles aTriangle
instance immediately (on the stack when executing in aStackContext
).- Parameters:
instance
- The instance to recycle immediately.
-
getP1
public Point getP1()
Return the first vertex in this triangle.- Specified by:
getP1
in classGeomTriangle
- Returns:
- The first vertex in this triangle.
-
getP2
public Point getP2()
Return the second vertex in this triangle.- Specified by:
getP2
in classGeomTriangle
- Returns:
- The second vertex in this triangle.
-
getP3
public Point getP3()
Return the third and last vertex in this triangle.- Specified by:
getP3
in classGeomTriangle
- Returns:
- The third and last vertex in this triangle.
-
getNormal
public Vector<javax.measure.quantity.Dimensionless> getNormal()
Return the surface unit normal vector for this triangle. If the triangle is degenerate (zero area), then the normal vector will have zero length.- Specified by:
getNormal
in classGeomTriangle
- Returns:
- The surface normal vector for this triangle.
-
getArea
public Parameter<javax.measure.quantity.Area> getArea()
Return the surface area of one side of this triangle. The returned area is always positive, but can be zero.- Specified by:
getArea
in classGeomTriangle
- Returns:
- The surface area of one side of this triangle.
-
reverse
public Triangle reverse()
Return a new triangle that is identical to this one, but with the order of the points (and the surface normal direction) reversed.- Specified by:
reverse
in classGeomTriangle
- Returns:
- A new Triangle that is identical to this one, but with the order of the points reversed.
-
getBoundsMin
public Point getBoundsMin()
Return the coordinate point representing the minimum bounding box corner of this geometry element (e.g.: min X, min Y, min Z).- Specified by:
getBoundsMin
in interfaceGeomElement<GeomTriangle>
- Returns:
- The minimum bounding box coordinate for this geometry element.
-
getBoundsMax
public Point getBoundsMax()
Return the coordinate point representing the maximum bounding box corner (e.g.: max X, max Y, max Z).- Specified by:
getBoundsMax
in interfaceGeomElement<GeomTriangle>
- Returns:
- The maximum bounding box coordinate for this geometry element.
-
getTransformed
public TriangleTrans getTransformed(GTransform transform)
Returns transformed version of this element. The returned object implementsGeomTransform
and contains this element as a child.- Specified by:
getTransformed
in interfaceTransformable<GeomTriangle>
- Parameters:
transform
- The transformation to apply to this geometry. May not be null.- Returns:
- A new triangle that is identical to this one with the specified transformation applied.
- Throws:
DimensionException
- if this point is not 3D.
-
toDimension
public Triangle toDimension(int newDim)
Return a copy of this Triangle converted to the specified number of physical dimensions. If the number of dimensions is greater than this element, then zeros are added to the additional dimensions. If the number of dimensions is less than this element, then the extra dimensions are simply dropped (truncated). If the new dimensions are the same as the dimension of this element, then this element is simply returned.- Specified by:
toDimension
in interfaceGeomElement<GeomTriangle>
- Parameters:
newDim
- The dimension of the Triangle to return.- Returns:
- This Triangle converted to the new dimensions.
-
to
public Triangle to(javax.measure.unit.Unit<javax.measure.quantity.Length> unit) throws javax.measure.converter.ConversionException
Returns the equivalent to this element but stated in the specified unit.- Specified by:
to
in interfaceGeomElement<GeomTriangle>
- Specified by:
to
in interfacePointGeometry<GeomTriangle>
- Parameters:
unit
- the length unit of the element to be returned. May not be null.- Returns:
- an equivalent to this element but stated in the specified unit.
- Throws:
javax.measure.converter.ConversionException
- if the the input unit is not a length unit.
-
copy
public Triangle copy()
Returns a copy of this Triangle instance allocated by the calling thread (possibly on the stack).- Specified by:
copy
in interfaceGeomElement<GeomTriangle>
- Specified by:
copy
in interfacejavolution.lang.ValueType
- Returns:
- an identical and independent copy of this Triangle.
-
copyToReal
public Triangle copyToReal()
Return a copy of this object with any transformations or subranges removed (applied).- Specified by:
copyToReal
in interfaceGeomElement<GeomTriangle>
- Returns:
- A copy of this object with any transformations or subranges removed (applied).
-
equals
public boolean equals(java.lang.Object obj)
Compares this Triangle against the specified object for strict equality.- Overrides:
equals
in classAbstractGeomElement<GeomTriangle>
- Parameters:
obj
- the object to compare with.- Returns:
true
if this Triangle is identical to that Triangle;false
otherwise.
-
hashCode
public int hashCode()
Returns the hash code for this parameter.- Overrides:
hashCode
in classAbstractGeomElement<GeomTriangle>
- Returns:
- the hash code value.
-
-