computeBarycentricCoordinates

fun computeBarycentricCoordinates(x: Double, y: Double, x1: Double, y1: Double, x2: Double, y2: Double, x3: Double, y3: Double, result: Cartesian3? = definedExternally): Cartesian3(source)

Compute the barycentric coordinates of a 2D position within a 2D triangle.

const result = Intersections2D.computeBarycentricCoordinates(0.0, 0.0, 0.0, 1.0, -1, -0.5, 1, -0.5);
// result === new Cartesian3(1.0 / 3.0, 1.0 / 3.0, 1.0 / 3.0);

Return

The barycentric coordinates of the position within the triangle.

Parameters

x

The x coordinate of the position for which to find the barycentric coordinates.

y

The y coordinate of the position for which to find the barycentric coordinates.

x1

The x coordinate of the triangle's first vertex.

y1

The y coordinate of the triangle's first vertex.

x2

The x coordinate of the triangle's second vertex.

y2

The y coordinate of the triangle's second vertex.

x3

The x coordinate of the triangle's third vertex.

y3

The y coordinate of the triangle's third vertex.

result

The instance into to which to copy the result. If this parameter is undefined, a new instance is created and returned.

See also