# LastOfTheCarelessMen/Vector

Change N0_index to take a degree \$p and return the start of the inter…

`…esting region rather than the end. Also swap LowerBound and UpperBound in it. Associated changes.`
• Loading branch information...
1 parent 6019a1d commit 4877b6afa9083d98b7ddb6290564337047c7a2cb SF committed Oct 20, 2009
Showing with 8 additions and 10 deletions.
1. +8 −10 lib/KnotVector.pm
 @@ -28,28 +28,26 @@ class KnotVector self.WHAT.perl ~ ".new((" ~ @.knots.map({.perl}).join(', ') ~ "))"; } - multi method N0_index(\$u, KnotBasisDirection \$direction = Left) + multi method N0_index(Int \$p, \$u, KnotBasisDirection \$direction = Left) { given \$direction { - when Left { LowerBound(@.knots, \$u); } - when Right { UpperBound(@.knots, \$u); } + when Left { UpperBound(@.knots, \$u) - \$p - 1; } + when Right { LowerBound(@.knots, \$u) - \$p - 1; } } } multi method N_local(Int \$n0, Int \$p, \$u, KnotBasisDirection \$direction = Left) { my @N_prev = 0 xx \$p, 1, 0; my @N = 0 xx (\$p + 2); - - my \$n0p = \$n0 - \$p - 1; - + for 1..\$p -> \$q { for (\$p - \$q)...(\$p) -> \$i { - @N[\$i] = ((\$u - @.knots[\$n0p + \$i]) O/ (@.knots[\$n0p + \$i + \$q] - @.knots[\$n0p + \$i])) * @N_prev[\$i] - + ((@.knots[\$n0p + \$i + \$q + 1] - \$u) O/ (@.knots[\$n0p + \$i + \$q + 1] - @.knots[\$n0p + \$i + 1])) * @N_prev[\$i + 1]; + @N[\$i] = ((\$u - @.knots[\$n0 + \$i]) O/ (@.knots[\$n0 + \$i + \$q] - @.knots[\$n0 + \$i])) * @N_prev[\$i] + + ((@.knots[\$n0 + \$i + \$q + 1] - \$u) O/ (@.knots[\$n0 + \$i + \$q + 1] - @.knots[\$n0 + \$i + 1])) * @N_prev[\$i + 1]; } @N_prev = @N; } @@ -60,9 +58,9 @@ class KnotVector multi method N(Int \$p, \$u, KnotBasisDirection \$direction = Left) { - my \$n0 = self.N0_index(\$u, \$direction); + my \$n0 = self.N0_index(\$p, \$u, \$direction); my @N = 0 xx (@.knots.elems - \$p - 1); - @N[(\$n0-\$p-1)..(\$n0-1)] = self.N_local(\$n0, \$p, \$u, \$direction); + @N[(\$n0)..(\$n0 + \$p)] = self.N_local(\$n0, \$p, \$u, \$direction); return @N; } }

#### 0 comments on commit `4877b6a`

Please sign in to comment.