BarycentricTriangle Class

3 points defining a triangle to be evaluated with barycentric coordinates.

Methods

Name Description
constructor(point0: Point3d, point1: Point3d, point2: Point3d): BarycentricTriangle Protected Constructor.  
centroid(result?: Point3d): Point3d Return the centroid of the 3 points.  
circumcenter(result?: Point3d): Point3d Return the circumcenter of the triangle.  
clone(result?: BarycentricTriangle): BarycentricTriangle Return a new BarycentricTriangle with the same coordinates.  
cloneTransformed(transform: Transform, result?: BarycentricTriangle): BarycentricTriangle Return a clone of the transformed instance  
closestPoint(b0: number, b1: number, b2: number): { closestEdgeIndex: number, closestEdgeParam: number } Compute the projection of a barycentric point p to the triangle T(v_0,v_1,v_2).  
closestVertexIndex(b0: number, b1: number, b2: number): number Return the index of the closest triangle vertex to the point given by its barycentric coordinates.  
distanceSquared(a0: number, a1: number, a2: number, b0: number, b1: number, b2: number): number Compute the squared distance between two points given by their barycentric coordinates.  
dotProductOfCrossProductsFromOrigin(other: BarycentricTriangle): number Return the dot product of the scaled normals of the two triangles.  
dotProductOfEdgeVectorsAtVertex(baseVertexIndex: number): number Compute dot product of the edge vectors based at the vertex with the given index.  
edgeLength(oppositeVertexIndex: number): number Compute length of the triangle edge opposite the vertex with the given index.  
edgeLengthSquared(oppositeVertexIndex: number): number Compute squared length of the triangle edge opposite the vertex with the given index.  
fractionToPoint(b0: number, b1: number, b2: number, result?: Point3d): Point3d Sum the triangle points with given scales.  
incenter(result?: Point3d): Point3d Return the incenter of the triangle.  
intersectRay3d(ray: Ray3d, result?: TriangleLocationDetail): TriangleLocationDetail Compute the intersection of a line (parameterized as a ray) with the plane of this triangle.  
intersectSegment(point0: Point3d, point1: Point3d, result?: TriangleLocationDetail): TriangleLocationDetail Compute the intersection of a line (parameterized as a line segment) with the plane of this triangle.  
isAlmostEqual(other: BarycentricTriangle, tol?: number): boolean Test for point-by-point isAlmostEqual relationship.  
normal(result?: Vector3d): undefined | Vector3d Return the unit normal of the triangle.  
pointToFraction(point: Point3d, result?: TriangleLocationDetail): TriangleLocationDetail Compute the projection of the given point onto the plane of this triangle.  
set(point0: undefined | Point3d, point1: undefined | Point3d, point2: undefined | Point3d): void Copy contents of (not pointers to) the given points.  
setFrom(other: BarycentricTriangle): void Copy all values from other  
snapLocationToEdge(location: TriangleLocationDetail, distanceTolerance: number = Geometry.smallMetricDistance, parameterTolerance: number = Geometry.smallFloatingPoint): boolean Adjust the location to the closest edge of the triangle if within either given tolerance.  
create(point0: Point3d, point1: Point3d, point2: Point3d, result?: BarycentricTriangle): BarycentricTriangle Static Create a triangle with coordinates cloned from given points.  
createXYZXYZXYZ(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, x2: number, y2: number, z2: number, result?: BarycentricTriangle): BarycentricTriangle Static Create a BarycentricTriangle with coordinates given by enumerated x,y,z of the 3 points.  
edgeOppositeVertexIndexToStartVertexIndex(edgeIndex: number): number Static Convert from opposite-vertex to start-vertex edge indexing.  
edgeStartVertexIndexToOppositeVertexIndex(startVertexIndex: number): number Static Convert from start-vertex to opposite-vertex edge indexing.  
isInsideOrOnTriangle(b0: number, b1: number, b2: number): boolean Static Examine a point's barycentric coordinates to determine if it lies inside the triangle or on an edge/vertex.  
isInsideTriangle(b0: number, b1: number, b2: number): boolean Static Examine a point's barycentric coordinates to determine if it lies inside the triangle but not on an edge/vertex.  

Properties

Name Type Description
area Accessor ReadOnly number Return the area of the triangle.  
aspectRatio Accessor ReadOnly number Return area divided by sum of squared lengths.  
edgeLength2 Protected number[] Edge length squared cache, indexed by opposite vertex index  
perimeter Accessor ReadOnly number Return the perimeter of the triangle.  
points Point3d[] Array of 3 point coordinates for the triangle.  

Defined in

Last Updated: 16 April, 2024