public class Triangle extends Object implements Serializable
Vertex
class).
This class also stores data related to the triangle for efficient computation (center, surface, normal vector,
neighboring Triangle
).Constructor and Description |
---|
Triangle(int idIn,
Vertex v1,
Vertex v2,
Vertex v3)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addNeighbors(Triangle neighbor)
Add a triangle neighbor (package method only to be used at initialization of
FacetBodyShape ). |
Vector3D[] |
closestPointTo(Line line)
Computes the points of the triangle and the line realizing the shortest distance.
|
protected double |
distanceTo(Line line)
Computes minimal distance between provided line and triangle provided that line does not cross triangle.
|
static double |
dotProduct(Vector3D v1,
Vector3D v2)
Fast dot product of two 3D vectors.
|
Vector3D |
getCenter()
Returns the triangle barycenter.
|
int |
getID()
The triangle identifier.
|
Vector3D |
getIntersection(Line line)
Returns intersection point with triangle, null if there is no intersection or if line is included in triangle.
|
List<Triangle> |
getNeighbors()
Returns the triangle neighbors (i.e.
|
Vector3D |
getNormal()
Returns the normal to the triangle.
|
double |
getSphereRadius()
Returns the encompassing sphere radius squared.
|
double |
getSurface()
Returns the triangle surface.
|
Vertex[] |
getVertices()
The triangle vertices.
|
boolean |
isHandled()
Returns a boolean representing triangle status for fast algorithms.
|
boolean |
isNeighborByVertexID(Triangle triangle)
Returns true if provided triangle is a neighbor by checking their vertices ID (i.e.
|
boolean |
isVisible(Vector3D position)
Returns true if the triangle is visible from the provided position (culling test).
|
boolean |
pointInTriangle(Vector3D point)
Check if the projection on triangle's plane of a point of space belongs to the triangle.
|
void |
setHandled(boolean handled)
Set a boolean representing triangle status for fast algorithms.
|
public Vector3D getIntersection(Line line)
Algorithm from article "Fast, Minimum Storage Ray/Triangle Intersection" from Thomas Moller, 1997.
line
- line of sight (considered infinite)public Vector3D[] closestPointTo(Line line)
Computes the points of the triangle and the line realizing the shortest distance.
If the line intersects the triangle, the returned points are identical. Semi-finite lines are handled by this
method.
line
- the linepublic final boolean pointInTriangle(Vector3D point)
point
- a point of spacepublic static final double dotProduct(Vector3D v1, Vector3D v2)
v1
- first vectorv2
- second vectorpublic int getID()
public Vertex[] getVertices()
public Vector3D getCenter()
public Vector3D getNormal()
public double getSurface()
public List<Triangle> getNeighbors()
public double getSphereRadius()
protected void addNeighbors(Triangle neighbor)
FacetBodyShape
).
Warning: no check is performed in order to verify is the provided triangle is really a neighbor.
neighbor
- the triangle neighbor to setpublic boolean isNeighborByVertexID(Triangle triangle)
triangle
- a trianglepublic boolean isVisible(Vector3D position)
position
- positionprotected double distanceTo(Line line)
This method is package-protected and is not supposed to be used by user. It assumes line does not cross triangle
line
- linepublic void setHandled(boolean handled)
handled
- status to setpublic boolean isHandled()
Copyright © 2023 CNES. All rights reserved.