Package: graphene

Function graphene:triangle-barycoords

Lambda List

graphene:triangle-barycoords (triangle point result)

Arguments

triangle -- a graphene:triangle-t instance
point -- a graphene:point3d-t instance
result -- a graphene:vec2-t instance for the vector with the barycentric coordinates

Return Value

The graphene:vec2-t instance with the barycentric coordinates, or nil if the result is not valid

Details

Computes the barycentric coordinates of the given point. The point must lie on the same plane as the triangle. If the point is not coplanar, the result of this function is undefined.

If we place the origin in the coordinates of the triangle's A point, the barycentric coordinates are u, which is on the AC vector, and v which is on the AB vector.

The returned vector contains the following values, in order:
result.x = u
result.y = v  
 

See also

#2023-12-8