Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Start working up tests for knot vector basis to polynomial conversion.

  • Loading branch information...
commit 5df5605c06c0a45dca08017dd67708ec632eaab6 1 parent dac79d1
SF authored
Showing with 36 additions and 2 deletions.
  1. +2 −2 lib/Polynomial.pm
  2. +34 −0 t/06-knots_poly.t
View
4 lib/Polynomial.pm
@@ -112,12 +112,12 @@ multi sub infix:<*>(Polynomial $a, Polynomial $b)
return Polynomial.new(@coef);
}
-multi sub infix:<*>(Polynomial $a, $b)
+multi sub infix:<*>(Polynomial $a, $b) is default
{
Polynomial.new($a.coefficients >>*>> $b);
}
-multi sub infix:<*>($b, Polynomial $a)
+multi sub infix:<*>($b, Polynomial $a) is default
{
Polynomial.new($a.coefficients >>*>> $b);
}
View
34 t/06-knots_poly.t
@@ -0,0 +1,34 @@
+use v6;
+use KnotVector;
+use Polynomial;
+use Nurbs;
+use Test;
+
+plan *;
+
+my KnotVector $kv = KnotVector.new((-1, -1, -1, -1, 1, 2, 2, 3, 3, 3, 3));
+my @control_points = (Vector.new(0, 0, 0),
+ Vector.new(1, 0, 0),
+ Vector.new(1, 1, 0),
+ Vector.new(0, 1, 0),
+ Vector.new(1, 2, 0),
+ Vector.new(1, 2, 1),
+ Vector.new(1, 2, -1));
+my Nubs $nubs = Nubs.new(3, $kv, @control_points);
+
+my @polys = Polynomial.new(0) xx 7;
+my $n0 = $kv.N0_index(1/2);
+@polys[($n0 - 4) .. ($n0 - 1)] = $kv.N_local($n0, 3, Polynomial.new(0, 1));
+
+for (-1, -1/2, 0, 1/2) -> $t
+{
+ my @values = @polys>>.evaluate($t);
+ my $value = [+] (@values >>*<< @control_points);
+ is_approx($value, $nubs.Evaluate($t), "Polynomial evaluation and sum == Nubs evaluation");
+ # my @frip = (@polys Z @control_points).map({ $^a * $^b });
+ # my $poly = [+] (@polys >>*<< @control_points);
+ # $poly.say;
+ # # @polys.map({ $_.evaluate(1/2).perl.say });
+}
+
+done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.