Package geomss.geom
Class GeomTriangle
- java.lang.Object
-
- geomss.geom.AbstractGeomElement<GeomTriangle>
-
- geomss.geom.GeomTriangle
-
- All Implemented Interfaces:
GeomElement<GeomTriangle>
,PointGeometry<GeomTriangle>
,Transformable<GeomTriangle>
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable
,javolution.lang.Reusable
,javolution.xml.XMLSerializable
- Direct Known Subclasses:
Triangle
,TriangleTrans
public abstract class GeomTriangle extends AbstractGeomElement<GeomTriangle> implements PointGeometry<GeomTriangle>, Transformable<GeomTriangle>
The interface and implementation in common to all triangles 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:
- February 16, 2016
- Author:
- Joseph A. Huwaldt, Date: August 26, 2015
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class geomss.geom.AbstractGeomElement
RESOURCES
-
-
Constructor Summary
Constructors Constructor Description GeomTriangle()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description GeomList<GeomPoint>
getAll()
Returns an newGeomList
containing the ordered points in this triangle.abstract Parameter<javax.measure.quantity.Area>
getArea()
Return the surface area of one side of this triangle.GeomPoint
getLimitPoint(int dim, boolean max, double tol)
Returns the most extreme point, either minimum or maximum, in the specified coordinate direction on this triangle.abstract GeomVector<javax.measure.quantity.Dimensionless>
getNormal()
Return the surface unit normal vector for this triangle.int
getNumberOfPoints()
Return the total number of points in this geometry element.abstract GeomPoint
getP1()
Return the first vertex in this triangle.abstract GeomPoint
getP2()
Return the second vertex in this triangle.abstract GeomPoint
getP3()
Return the third and last vertex in this triangle.int
getParDimension()
Returns the number of parametric dimensions of the geometry element.int
getPhyDimension()
Returns the number of physical dimensions of the geometry element.PointString<? extends GeomPoint>
getPoints()
Return all three vertices of this triangle as an ordered list of points.GeomPoint[]
getPoints(GeomPoint[] points)
Return all three vertices of this triangle contained in the supplied array of points.javax.measure.unit.Unit<javax.measure.quantity.Length>
getUnit()
Returns the unit in which this GeomTriangle is stated.boolean
isDegenerate(Parameter<javax.measure.quantity.Length> tol)
Returntrue
if this triangle is degenerate (i.e.: has zero surface area).boolean
isValid()
Returntrue
if this GeomTriangle contains valid and finite numerical components.void
reset()
Resets the internal state of this object to its default values.abstract GeomTriangle
reverse()
Return a new triangle that is identical to this one, but with the order of the points (and the surface normal direction) reversed.int
size()
Returns the number of child-elements that make up this geometry element.javolution.text.Text
toText()
Returns the text representation of this geometry element that consists of the name followed by the three defining points.-
Methods inherited from class geomss.geom.AbstractGeomElement
addChangeListener, clone, compareTo, equals, getAllUserData, getID, getName, getUserData, hashCode, putAllUserData, putUserData, removeChangeListener, removeUserData, setName, toString
-
Methods inherited from interface geomss.geom.GeomElement
addChangeListener, copy, copyToReal, getAllUserData, getBoundsMax, getBoundsMin, getID, getName, getUserData, putAllUserData, putUserData, removeChangeListener, removeUserData, setName, toDimension
-
Methods inherited from interface geomss.geom.PointGeometry
to
-
Methods inherited from interface geomss.geom.Transformable
getTransformed
-
-
-
-
Constructor Detail
-
GeomTriangle
public GeomTriangle()
-
-
Method Detail
-
getP1
public abstract GeomPoint getP1()
Return the first vertex in this triangle.- Returns:
- The first vertex in this triangle.
-
getP2
public abstract GeomPoint getP2()
Return the second vertex in this triangle.- Returns:
- The second vertex in this triangle.
-
getP3
public abstract GeomPoint getP3()
Return the third and last vertex in this triangle.- Returns:
- The third and last vertex in this triangle.
-
getNormal
public abstract GeomVector<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.- Returns:
- The surface normal vector for this triangle.
-
getArea
public abstract 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.- Returns:
- The surface area of one side of this triangle.
-
isDegenerate
public boolean isDegenerate(Parameter<javax.measure.quantity.Length> tol)
Returntrue
if this triangle is degenerate (i.e.: has zero surface area). A degenerate triangle is defined as a triangle that has any edge with length less than the input tolerance.- Parameters:
tol
- The tolerance for determining if this triangle is degenerate. A value ofnull
would indicate that exactly zero area is required to be degenerate.- Returns:
- true if this triangle is degenerate.
-
reverse
public abstract GeomTriangle reverse()
Return a new triangle that is identical to this one, but with the order of the points (and the surface normal direction) reversed.- Returns:
- A new Triangle that is identical to this one, but with the order of the points reversed.
-
getPoints
public PointString<? extends GeomPoint> getPoints()
Return all three vertices of this triangle as an ordered list of points.- Returns:
- A list containing the three vertices of this triangle in counter-clockwise order.
-
getPoints
public GeomPoint[] getPoints(GeomPoint[] points)
Return all three vertices of this triangle contained in the supplied array of points. The input array must have at least 3 elements.- Parameters:
points
- An existing array with at leat 3 elements that will be filled in with points from this triangle. May not be null.- Returns:
- The input array with the three vertices of this triangle, in counter- clockwise order, placed in the 1st 3 elements.
-
getAll
public GeomList<GeomPoint> getAll()
Returns an newGeomList
containing the ordered points in this triangle.- Returns:
- A new GeomList containing the ordered points from this triangle.
-
size
public int size()
Returns the number of child-elements that make up this geometry element. This implementation always returns 3 as a GeomTriangle has three vertices.- Specified by:
size
in interfaceGeomElement<GeomTriangle>
- Returns:
- The number of points in this triangle (always returns 3).
-
getPhyDimension
public int getPhyDimension()
Returns the number of physical dimensions of the geometry element.- Specified by:
getPhyDimension
in interfaceGeomElement<GeomTriangle>
- Returns:
- The number of physical dimensions of this geometry element.
-
getParDimension
public int getParDimension()
Returns the number of parametric dimensions of the geometry element. This implementation always returns 0 as a Triangle is not parametric.- Specified by:
getParDimension
in interfaceGeomElement<GeomTriangle>
- Returns:
- The number of parametric dimensions of this geometry element.
-
getNumberOfPoints
public int getNumberOfPoints()
Return the total number of points in this geometry element. This implementation always returns 3 as a GeomTriangle has three vertices.- Specified by:
getNumberOfPoints
in interfacePointGeometry<GeomTriangle>
- Returns:
- Always returns 3.
-
getLimitPoint
public GeomPoint getLimitPoint(int dim, boolean max, double tol)
Returns the most extreme point, either minimum or maximum, in the specified coordinate direction on this triangle.- Specified by:
getLimitPoint
in interfaceGeomElement<GeomTriangle>
- Parameters:
dim
- An index indicating the dimension to find the min/max point for (0=X, 1=Y, 2=Z, etc).max
- Set totrue
to return the maximum value,false
to return the minimum.tol
- Fractional tolerance (in parameter space) to refine the min/max point position to.- Returns:
- The point found on this triangle that is the min or max in the specified coordinate direction.
- See Also:
GeomElement.getBoundsMin()
,GeomElement.getBoundsMax()
-
isValid
public boolean isValid()
Returntrue
if this GeomTriangle contains valid and finite numerical components. A value offalse
will be returned if any of the coordinate values are NaN or Inf.- Specified by:
isValid
in interfaceGeomElement<GeomTriangle>
- Returns:
- true if this GeomTriangle contains valid and finite data.
-
getUnit
public javax.measure.unit.Unit<javax.measure.quantity.Length> getUnit()
Returns the unit in which this GeomTriangle is stated.- Specified by:
getUnit
in interfaceGeomElement<GeomTriangle>
- Returns:
- The unit in which this GeomTriangle is stated.
-
toText
public javolution.text.Text toText()
Returns the text representation of this geometry element that consists of the name followed by the three defining points. For example:{aTri = {{0.0 m, 0.0 m},{1.0 m, 0.0 m},{0.5 m, 1.0 m}}
If there is no name, then the output looks like this:{{0.0 m, 0.0 m},{1.0 m, 0.0 m},{0.5 m, 1.0 m}}
- Specified by:
toText
in interfaceGeomElement<GeomTriangle>
- Overrides:
toText
in classAbstractGeomElement<GeomTriangle>
- Returns:
- the text representation of this geometry element.
-
reset
public void reset()
Resets the internal state of this object to its default values. Subclasses that override this method must callsuper.reset();
to ensure that the state is reset properly.- Specified by:
reset
in interfacejavolution.lang.Reusable
- Overrides:
reset
in classAbstractGeomElement<GeomTriangle>
-
-