Skip to content

Instantly share code, notes, and snippets.

@LastOfTheCarelessMen
Created November 2, 2009 12:56
Show Gist options
  • Save LastOfTheCarelessMen/224144 to your computer and use it in GitHub Desktop.
Save LastOfTheCarelessMen/224144 to your computer and use it in GitHub Desktop.
multi method KnotVector.N0_index(Int $p, $u, KnotBasisDirection $direction = Left)
{
given $direction
{
when Left { UpperBound(@.knots, $u) - $p - 1; }
when Right { LowerBound(@.knots, $u) - $p - 1; }
when Reasonable { die "Must specify Left or Right for KnotBasisDirection"; }
}
}
multi method Nubs.Direction($t, KnotBasisDirection $direction)
{
return $t < ([+] self.ParameterRange) / 2 ?? Left !! Right
if ($direction == Reasonable);
return $direction;
}
multi method Nubs.evaluate($t, KnotBasisDirection $direction = Reasonable)
{
my $n0 = $.knot_vector.N0_index($.degree, $t, Direction($t, $direction));
return [+] ($.knot_vector.N_local($n0, $.degree, $t)
>>*<< @.control_points[$n0 .. ($n0 + $.degree)]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment