calcSurfacePoint static method

void calcSurfacePoint(
  1. int p,
  2. int q,
  3. List<double> U,
  4. List<double> V,
  5. List<List<Vector4>> P,
  6. double u,
  7. double v,
  8. Vector target,
)

Implementation

static void calcSurfacePoint(
  int p,
  int q,
  List<double> U,
  List<double> V,
  List<List<Vector4>> P,
  double u,
  double v,
  Vector 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 List<Vector4> temp = [];

  for ( int l = 0; l <= q; ++ l ) {
    temp.add(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.scale( nu[ k ] ) );
    }
  }

  Vector4 sw = Vector4( 0, 0, 0, 0 );
  for ( int l = 0; l <= q; ++ l ) {
    sw.add( temp[ l ].scale( nv[ l ] ) );
  }

  sw.divideScalar( sw.w );
  if(target is Vector4){
    target.setValues( sw.x, sw.y, sw.z);
  }
  else if(target is Vector3){
    target.setValues( sw.x, sw.y, sw.z );
  }
  else{
    target.setValues( sw.x, sw.y);
  }
}