barycentricCoordinates

external fun barycentricCoordinates(point: Cartesian3, p0: Cartesian3, p1: Cartesian3, p2: Cartesian3, result: Cartesian3? = definedExternally): Cartesian3?(source)

Computes the barycentric coordinates for a point with respect to a triangle.

// Returns Cartesian3.UNIT_X
const p = new Cartesian3(-1.0, 0.0, 0.0);
const b = barycentricCoordinates(p,
new Cartesian3(-1.0, 0.0, 0.0),
new Cartesian3( 1.0, 0.0, 0.0),
new Cartesian3( 0.0, 1.0, 1.0));

Return

The modified result parameter or a new Cartesian3 instance if one was not provided. If the triangle is degenerate the function will return undefined.

Parameters

point

The point to test.

p0

The first point of the triangle, corresponding to the barycentric x-axis.

p1

The second point of the triangle, corresponding to the barycentric y-axis.

p2

The third point of the triangle, corresponding to the barycentric z-axis.

result

The object onto which to store the result.

See also