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.
|
Vector3D |
closestPointTo(Vector3D point)
Getter for the closest point of triangle to provided point.
|
protected double |
distanceTo(Line line)
Computes minimal distance between provided line and triangle provided that the line does not cross this
triangle.
|
double |
distanceTo(Vector3D point)
Computes distance from triangle to provided.
|
static double |
dotProduct(Vector3D v1,
Vector3D v2)
Fast dot product of two 3D vectors.
|
Vector3D |
getCenter()
Getter for the triangle barycenter.
|
int |
getID()
Getter for the triangle identifier.
|
Vector3D |
getIntersection(Line line)
Getter for the intersection point with triangle, null if there is no intersection or if line is included in
triangle.
|
List<Triangle> |
getNeighbors()
Getter for the triangle neighbors (i.e.
|
Vector3D |
getNormal()
Getter for the normal to the triangle.
|
double |
getSphereRadius()
Getter for the encompassing sphere radius squared.
|
double |
getSurface()
Getter for the triangle surface.
|
Vertex[] |
getVertices()
Getter for 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.
|
String |
toString() |
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)
If the line intersects the triangle, the returned points are identical. Semi-finite lines are handled by this method.
line
- the linepublic Vector3D closestPointTo(Vector3D point)
point
- a pointpublic 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 that the line does not cross this triangle.
line
- linepublic double distanceTo(Vector3D point)
point
- pointpublic void setHandled(boolean handled)
handled
- status to setpublic boolean isHandled()
Copyright © 2023 CNES. All rights reserved.