Skip to content

Instantly share code, notes, and snippets.

@LastOfTheCarelessMen
Created November 3, 2009 08:26
Show Gist options
  • Save LastOfTheCarelessMen/224897 to your computer and use it in GitHub Desktop.
Save LastOfTheCarelessMen/224897 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; }
}
}
multi method Nubs.Direction($t)
{
$t < ([+] self.ParameterRange) / 2 ?? Left !! Right;
}
multi method Nubs.evaluate($t, KnotBasisDirection $direction = self.Direction($t))
{
my $n0 = $.knot_vector.N0_index($.degree, $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