Class MeshTriangleImpl
java.lang.Object
cz.fidentis.analyst.data.mesh.impl.MeshTriangleImpl
- All Implemented Interfaces:
MeshTriangle
,Serializable
,Iterable<MeshPoint>
Adapter for the corner table representing a single triangle of
MeshFacet
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface cz.fidentis.analyst.data.mesh.MeshTriangle
MeshTriangle.Smoothing
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMeshTriangleImpl
(MeshFacet facet, int i1, int i2, int i3) Creates new triangle -
Method Summary
Modifier and TypeMethodDescriptionjavax.vecmath.Vector3d
Computes and returns normalized normal vector from the vertices.boolean
protected javax.vecmath.Point3d
getBarycentricCoords
(javax.vecmath.Vector3d[] cross) javax.vecmath.Point3d
getClosestPoint
(javax.vecmath.Point3d point) Computes the point laying on the triangle which is closest to given 3D point.List
<javax.vecmath.Point3d> getCommonPoints
(MeshTriangle other) Selects the common points shared by two trianglesjavax.vecmath.Vector4d
getCurvatureOfTrianglePlane
(javax.vecmath.Point3d samplePosition, double distanceAccepted, javax.vecmath.Vector3d base1, javax.vecmath.Vector3d base2) Function tests if the mesh triangle is closer to the sample point than a certain distance and if is, calculates the second fundamental form of the sample point regarding the plane defined by the mesh triangle, otherwise returns null.protected static javax.vecmath.Vector3d
getEdge
(javax.vecmath.Point3d v1, javax.vecmath.Point3d v2) getFacet()
Returns mesh facet backing the triangle.int
Returns the index under which the vertex is stored in the array of facet verticesint
Returns the index under which the vertex is stored in the array of facet verticesint
Returns the index under which the vertex is stored in the array of facet verticesprotected javax.vecmath.Point3d
getInterpolatedIntersection
(javax.vecmath.Tuple3d barycentricCoords, javax.vecmath.Vector3d[] inner) Calculates new position of a point from thr triangle so that the point lies on "smoothed" surface interpolated by normal in triangle vertices.protected javax.vecmath.Vector3d
getInterpolatedNormal
(javax.vecmath.Tuple3d barycentricCoords) Calculates interpolated normal of a point, weights = barycentric coordinatesprotected static boolean
getLinesIntersection
(javax.vecmath.Point3d origin, javax.vecmath.Vector3d vector, javax.vecmath.Point3d first, javax.vecmath.Point3d second, javax.vecmath.Point3d intersection) Computes the intersection between an infinite line and its coplanar lines segment.Returns mesh point of the triangle's vertex.Returns mesh point of the triangle's vertex.Returns mesh point of the triangle's vertex.protected javax.vecmath.Point3d
getProjectionToClosestEdge
(javax.vecmath.Point3d point) Computes projection of tmp1 3D point laying on the plane of the triangle to the nearest edge of the triangleprotected javax.vecmath.Point3d
getProjectionToEdge
(javax.vecmath.Point3d point, javax.vecmath.Point3d v1, javax.vecmath.Point3d v2) Computes projection to edgegetRayIntersection
(Ray ray, MeshTriangle.Smoothing smoothing) Computes ray-triangle intersection.javax.vecmath.Point3d
Returns 3D coordinates of the triangle's vertex.javax.vecmath.Point3d
Returns 3D coordinates of the triangle's vertex.javax.vecmath.Point3d
Returns 3D coordinates of the triangle's vertex.javax.vecmath.Point3d
Return a center of circumcircle.int
hashCode()
boolean
checkIntersectionWithPlane
(javax.vecmath.Vector3d normal, double d) Checks whether the triangle is intersected by a planeprotected boolean
isPointInTriangle
(javax.vecmath.Point3d point, javax.vecmath.Vector3d normal, javax.vecmath.Vector3d[] edges, javax.vecmath.Vector3d[] inner, javax.vecmath.Vector3d[] cross) Checks if point lying on the plane of the triangle also lies inside the triangle boundaries.iterator()
protected boolean
orientNormal
(javax.vecmath.Vector3d normal) Orient given triangle normal so that it is in the direction of the normals of vertices of the triangle.protected javax.vecmath.Vector3d
subtractPosition
(javax.vecmath.Point3d p1, MeshPoint p2) toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EPS
public static final double EPS- See Also:
-
index1
public final int index1Under which index is the corresponding vertex stored in the mesh facet -
index2
public final int index2 -
index3
public final int index3
-
-
Constructor Details
-
MeshTriangleImpl
Creates new triangle- Parameters:
facet
- Mesh faceti1
- which index is the first vertex stored in the mesh faceti2
- which index is the second vertex stored in the mesh faceti3
- which index is the third vertex stored in the mesh facet
-
-
Method Details
-
getFacet
Description copied from interface:MeshTriangle
Returns mesh facet backing the triangle.- Specified by:
getFacet
in interfaceMeshTriangle
- Returns:
- mesh facet backing the triangle.
-
getVertex1
public javax.vecmath.Point3d getVertex1()Description copied from interface:MeshTriangle
Returns 3D coordinates of the triangle's vertex.- Specified by:
getVertex1
in interfaceMeshTriangle
- Returns:
- 3D coordinates of the triangle's vertex
-
getVertex2
public javax.vecmath.Point3d getVertex2()Description copied from interface:MeshTriangle
Returns 3D coordinates of the triangle's vertex.- Specified by:
getVertex2
in interfaceMeshTriangle
- Returns:
- 3D coordinates of the triangle's vertex
-
getVertex3
public javax.vecmath.Point3d getVertex3()Description copied from interface:MeshTriangle
Returns 3D coordinates of the triangle's vertex.- Specified by:
getVertex3
in interfaceMeshTriangle
- Returns:
- 3D coordinates of the triangle's vertex
-
getPoint1
Description copied from interface:MeshTriangle
Returns mesh point of the triangle's vertex.- Specified by:
getPoint1
in interfaceMeshTriangle
- Returns:
- mesh point of the triangle's vertex
-
getPoint2
Description copied from interface:MeshTriangle
Returns mesh point of the triangle's vertex.- Specified by:
getPoint2
in interfaceMeshTriangle
- Returns:
- mesh point of the triangle's vertex
-
getPoint3
Description copied from interface:MeshTriangle
Returns mesh point of the triangle's vertex.- Specified by:
getPoint3
in interfaceMeshTriangle
- Returns:
- mesh point of the triangle's vertex
-
getIndex1
public int getIndex1()Description copied from interface:MeshTriangle
Returns the index under which the vertex is stored in the array of facet vertices- Specified by:
getIndex1
in interfaceMeshTriangle
- Returns:
- the index under which the vertex is stored in the array of facet vertices
-
getIndex2
public int getIndex2()Description copied from interface:MeshTriangle
Returns the index under which the vertex is stored in the array of facet vertices- Specified by:
getIndex2
in interfaceMeshTriangle
- Returns:
- the index under which the vertex is stored in the array of facet vertices
-
getIndex3
public int getIndex3()Description copied from interface:MeshTriangle
Returns the index under which the vertex is stored in the array of facet vertices- Specified by:
getIndex3
in interfaceMeshTriangle
- Returns:
- the index under which the vertex is stored in the array of facet vertices
-
equals
-
hashCode
public int hashCode() -
computeOrientedNormal
public javax.vecmath.Vector3d computeOrientedNormal()Description copied from interface:MeshTriangle
Computes and returns normalized normal vector from the vertices. This vector is in the direction of the normals of vertices of the triangle.- Specified by:
computeOrientedNormal
in interfaceMeshTriangle
- Returns:
- normalized normal vector from the vertices.
-
getRayIntersection
Description copied from interface:MeshTriangle
Computes ray-triangle intersection. Based on this article but adapted to two-side triangles.- Specified by:
getRayIntersection
in interfaceMeshTriangle
- Parameters:
ray
- a raysmoothing
- smoothing strategy- Returns:
- the ray intersection or
null
-
getClosestPoint
public javax.vecmath.Point3d getClosestPoint(javax.vecmath.Point3d point) Description copied from interface:MeshTriangle
Computes the point laying on the triangle which is closest to given 3D point. Return point is either one of the triangle's vertices, a point laying on triangles edge, or a point laying on the plane of the triangle inside the triangle boundaries.- Specified by:
getClosestPoint
in interfaceMeshTriangle
- Parameters:
point
- 3D point- Returns:
- the closest point or
null
if the input parameter is missing
-
checkIntersectionWithPlane
public boolean checkIntersectionWithPlane(javax.vecmath.Vector3d normal, double d) Description copied from interface:MeshTriangle
Checks whether the triangle is intersected by a plane- Specified by:
checkIntersectionWithPlane
in interfaceMeshTriangle
- Parameters:
normal
- normal defining the planed
- distance defining the plane- Returns:
- true if the triangle is intersected by the plane
-
getCommonPoints
Description copied from interface:MeshTriangle
Selects the common points shared by two triangles- Specified by:
getCommonPoints
in interfaceMeshTriangle
- Parameters:
other
- The other triangle- Returns:
- the common points of two triangles
-
iterator
- Specified by:
iterator
in interfaceIterable<MeshPoint>
- Specified by:
iterator
in interfaceMeshTriangle
-
getVoronoiPoint
public javax.vecmath.Point3d getVoronoiPoint()Description copied from interface:MeshTriangle
Return a center of circumcircle. This point represents the point of Voronoi area used for Delaunay triangulation, for instance.- Specified by:
getVoronoiPoint
in interfaceMeshTriangle
- Returns:
- the center of circumcircle
-
toString
-
getEdge
protected static javax.vecmath.Vector3d getEdge(javax.vecmath.Point3d v1, javax.vecmath.Point3d v2) -
isPointInTriangle
protected boolean isPointInTriangle(javax.vecmath.Point3d point, javax.vecmath.Vector3d normal, javax.vecmath.Vector3d[] edges, javax.vecmath.Vector3d[] inner, javax.vecmath.Vector3d[] cross) Checks if point lying on the plane of the triangle also lies inside the triangle boundaries.- Parameters:
point
- Point located on the plane of the trianglenormal
- Normal vectoredges
- An array of vectors A->B, B->C, and C->A. If some of them is missing, then is computed automatically and stored in the array.inner
- An array of vectors A->P, B->P, and C->P. If some of them is missing, then is computed automatically and stored in the array.cross
- An output array of cross products A->B x A->P, etc.- Returns:
- true if point is in triangle, false otherwise
-
orientNormal
protected boolean orientNormal(javax.vecmath.Vector3d normal) Orient given triangle normal so that it is in the direction of the normals of vertices of the triangle.- Parameters:
normal
- normalized normal vector to be oriented. The vector can be inverted!- Returns:
true
if the normal direction was inverted
-
getProjectionToClosestEdge
protected javax.vecmath.Point3d getProjectionToClosestEdge(javax.vecmath.Point3d point) Computes projection of tmp1 3D point laying on the plane of the triangle to the nearest edge of the triangle- Parameters:
point
- point laying on the plane of the triangle- Returns:
- perpendicular projection to the nearest edge
-
getProjectionToEdge
protected javax.vecmath.Point3d getProjectionToEdge(javax.vecmath.Point3d point, javax.vecmath.Point3d v1, javax.vecmath.Point3d v2) Computes projection to edge- Parameters:
point
- Point laying on the plane of the trianglev1
- first vertex of edgev2
- second vertex of edge- Returns:
- projection to edge
-
subtractPosition
-
getInterpolatedNormal
protected javax.vecmath.Vector3d getInterpolatedNormal(javax.vecmath.Tuple3d barycentricCoords) Calculates interpolated normal of a point, weights = barycentric coordinates- Parameters:
barycentricCoords
- barycentric coordinates are returned bygetBarycentricCoords(Vector3d[])
- Returns:
- interpolated normal
-
getInterpolatedIntersection
protected javax.vecmath.Point3d getInterpolatedIntersection(javax.vecmath.Tuple3d barycentricCoords, javax.vecmath.Vector3d[] inner) Calculates new position of a point from thr triangle so that the point lies on "smoothed" surface interpolated by normal in triangle vertices. Based on algorithm.- Parameters:
barycentricCoords
- barycentric coordinates of the triangle as returned bygetBarycentricCoords(Vector3d[])
inner
- An array of vertex->point vectors returned byisPointInTriangle(Point3d, Vector3d, Vector3d[], Vector3d[], Vector3d[])
- Returns:
- interpolated point
-
getBarycentricCoords
protected javax.vecmath.Point3d getBarycentricCoords(javax.vecmath.Vector3d[] cross) -
getLinesIntersection
protected static boolean getLinesIntersection(javax.vecmath.Point3d origin, javax.vecmath.Vector3d vector, javax.vecmath.Point3d first, javax.vecmath.Point3d second, javax.vecmath.Point3d intersection) Computes the intersection between an infinite line and its coplanar lines segment. The infinite line is described like a ray, i.e., it has an origin and direction. But the intersection is searched in both directions. Negative length of returned ray indicates that the intersection point lies opposite direction than the input first segment expected.- Parameters:
origin
- starting point of first line Must not benull
vector
- unit direction vector of the first line. Must not benull
first
- first point on second line Must not benull
second
- second point on second line Must not benull
intersection
- output parameter storing the coordinates of the intersection. The point is set to (infinity, infinity, infinity) if the lines are parallel, or they don't lie at the same line.- Returns:
false
if the intersection point lies in the opposite direction than the input first segment expected.
-
getCurvatureOfTrianglePlane
public javax.vecmath.Vector4d getCurvatureOfTrianglePlane(javax.vecmath.Point3d samplePosition, double distanceAccepted, javax.vecmath.Vector3d base1, javax.vecmath.Vector3d base2) Description copied from interface:MeshTriangle
Function tests if the mesh triangle is closer to the sample point than a certain distance and if is, calculates the second fundamental form of the sample point regarding the plane defined by the mesh triangle, otherwise returns null.For more details, see: V. Interrante et al.: Conveying the 3D shape of smoothly curving transparent surfaces via texture, 1997, doi: 10.1109/2945.597794
- Specified by:
getCurvatureOfTrianglePlane
in interfaceMeshTriangle
- Parameters:
samplePosition
- position of a point on model's surface selected to be a glyphdistanceAccepted
- squared distance; the triangle needs to be closer to the sample point than this distance to be taken into accountbase1
- first vector of orthogonal base; the base consists of three vectors: the normal of the sample point and two vectors(base1 and base2) defining the tangent plane of the model at the sample pointbase2
- second vector of orthogonal base; the base consists of three vectors: the normal of the sample point and two vectors(base1 and base2) defining the tangent plane of the model at the sample point- Returns:
- curvature of the sample point represented by the rate the surface normal tips in the directions of orthogonal base
-