getPoint method

  1. @override
Vector3 getPoint(
  1. num t, [
  2. Vector? optionalTarget
])
override

Implementation

@override
	Vector3 getPoint(num t, [Vector? optionalTarget]) {
  if(optionalTarget == null || optionalTarget is! Vector3){
    if(optionalTarget == null){
      optionalTarget = Vector3();
    }
    else if(optionalTarget is Vector4){
      optionalTarget = Vector3(optionalTarget.x,optionalTarget.y,optionalTarget.z);
    }
    else{
      optionalTarget = Vector3(optionalTarget.x,optionalTarget.y);
    }
  }
		Vector3 point = optionalTarget;

		final u = knots[startKnot ] + t * (knots[endKnot ] - knots[startKnot ] ); // linear mapping t->u

		// following results in (wx, wy, wz, w) homogeneous point
		Vector4 hpoint = NURBSutils.calcBSplinePoint(degree,knots,controlPoints, u );

		if ( hpoint.w != 1.0 ) {

			// project to 3D space: (wx, wy, wz, w) -> (x, y, z, 1)
			hpoint.divideScalar( hpoint.w );

		}

		return point.setValues( hpoint.x, hpoint.y, hpoint.z );
	}