calcSurfacePoint function

void 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

void calcSurfacePoint( p, q, U, V, P, u, v, target ) {
	final uspan = findSpan( p, u, U );
	final vspan = findSpan( q, v, V );
	final nu = calcBasisFunctions( uspan, u, p, U );
	final nv = calcBasisFunctions( vspan, v, q, V );
	final temp = [];

	for ( int l = 0; l <= q; ++ l ) {
		temp[ l ] = Vector4( 0, 0, 0, 0 );
		for ( int k = 0; k <= p; ++ k ) {
			final point = P[ uspan - p + k ][ vspan - q + l ].clone();
			final 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 ( int l = 0; l <= q; ++ l ) {
		sw.add( temp[ l ].multiplyScalar( nv[ l ] ) );
	}

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