Created
November 2, 2009 12:56
-
-
Save LastOfTheCarelessMen/224144 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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