calcSurfacePoint function

dynamic calcSurfacePoint(
  1. dynamic p,
  2. dynamic q,
  3. dynamic U,
  4. dynamic V,
  5. dynamic P,
  6. dynamic u,
  7. dynamic v,
  8. dynamic target,
)

Implementation

calcSurfacePoint( p, q, U, V, P, u, v, target ) {

	var uspan = findSpan( p, u, U );
	var vspan = findSpan( q, v, V );
	var Nu = calcBasisFunctions( uspan, u, p, U );
	var Nv = calcBasisFunctions( vspan, v, q, V );
	var temp = [];

	for ( var l = 0; l <= q; ++ l ) {

		temp[ l ] = new Vector4( 0, 0, 0, 0 );
		for ( var k = 0; k <= p; ++ k ) {

			var point = P[ uspan - p + k ][ vspan - q + l ].clone();
			var w = point.w;
			point.x *= w;
			point.y *= w;
			point.z *= w;
			temp[ l ].add( point.multiplyScalar( Nu[ k ] ) );

		}

	}

	Vector4 Sw = Vector4( 0, 0, 0, 0 );
	for ( var l = 0; l <= q; ++ l ) {

		Sw.add( temp[ l ].multiplyScalar( Nv[ l ] ) );

	}

	Sw.divideScalar( Sw.w );
	target.set( Sw.x, Sw.y, Sw.z );

}