staticGetInterpolation static method

Vector staticGetInterpolation(
  1. Vector3 point,
  2. Vector3 p1,
  3. Vector3 p2,
  4. Vector3 p3,
  5. Vector v1,
  6. Vector v2,
  7. Vector v3,
  8. Vector target,
)

Computes the value barycentrically interpolated for the given point on the triangle. Returns null if the triangle is degenerate.

Vector3 point - Position of interpolated point. Vector3 p1 - The first corner of the triangle. Vector3 p2 - The second corner of the triangle. Vector3 p3 - The third corner of the triangle. Vector3 v1 - Value to interpolate of first vertex. Vector3 v2 - Value to interpolate of second vertex. Vector3 v3 - Value to interpolate of third vertex. Vector3 target - The target vector that is used to store the method's result. return Vector3? The interpolated value.

Implementation

static Vector staticGetInterpolation(Vector3 point, Vector3 p1, Vector3 p2, Vector3 p3, Vector v1, Vector v2, Vector v3, Vector target ) {
	// if (staticGetBarycoord( point, p1, p2, p3, _v3 ) == null ) {
	// 	target.x = 0;
	// 	target.y = 0;
	// 	if ( 'z' in target ) target.z = 0;
	// 	if ( 'w' in target ) target.w = 0;
	// 	return null;
	// }

	target.setScalar( 0 );
	target.addScaled( v1, _v3.x );
	target.addScaled( v2, _v3.y );
	target.addScaled( v3, _v3.z );

	return target;
}