changeset 12518:16602e56a2ca octave-forge

Added some tests
author rafavzqz
date Mon, 01 Sep 2014 16:15:19 +0000
parents dca94127b8c5
children ca003c383f0b
files extra/nurbs/inst/nrbpermute.m extra/nurbs/inst/nrbreverse.m extra/nurbs/inst/nrbtransp.m
diffstat 3 files changed, 45 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/extra/nurbs/inst/nrbpermute.m	Mon Sep 01 15:36:45 2014 +0000
+++ b/extra/nurbs/inst/nrbpermute.m	Mon Sep 01 16:15:19 2014 +0000
@@ -54,4 +54,19 @@
 %! vol.coefs(1,:,:) = vol.coefs(1,:,:) + 2;
 %! vol = nrbpermute(vol,[2 3 1]);
 %! nrbplot(vol,[5 10 20]);
-%! hold off
\ No newline at end of file
+%! hold off
+
+%!test
+%! vol = nrbrevolve (nrb4surf ([1 0], [2 0], [1 1], [2 1]), [0 0 0], [0 1 0], pi/8);
+%! perm1 = [1 3 2];
+%! perm2 = [2 1 3];
+%! vol2 = nrbpermute (vol, perm1);
+%! vol3 = nrbpermute (vol, perm2);
+%! assert (vol.number(perm1), vol2.number)
+%! assert (vol.order(perm1), vol2.order)
+%! assert ({vol.knots{perm1}}, vol2.knots)
+%! assert (permute(vol.coefs, [1, perm1+1]), vol2.coefs)
+%! assert (vol.number(perm2), vol3.number)
+%! assert (vol.order(perm2), vol3.order)
+%! assert ({vol.knots{perm2}}, vol3.knots)
+%! assert (permute(vol.coefs, [1, perm2+1]), vol3.coefs)
--- a/extra/nurbs/inst/nrbreverse.m	Mon Sep 01 15:36:45 2014 +0000
+++ b/extra/nurbs/inst/nrbreverse.m	Mon Sep 01 16:15:19 2014 +0000
@@ -78,4 +78,23 @@
 %! hold on
 %! nrbplot(crv2,100)
 %! title('The curve and its reverse are the same')
-%! hold off
\ No newline at end of file
+%! hold off
+
+%!test
+%! srf  = nrbrevolve(nrbline([1 0],[2 0]), [0 0 0], [0 0 1], pi/2);
+%! srf  = nrbkntins (srf, {0.3, 0.6});
+%! srf2 = nrbreverse (srf);
+%! assert (srf.knots, cellfun(@(x) sort(1-x), srf2.knots, 'UniformOutput', false), 1e-15)
+%! assert (srf.coefs, srf2.coefs(:,end:-1:1,end:-1:1))
+
+%!test
+%! srf  = nrbrevolve(nrbline([1 0],[2 0]), [0 0 0], [0 0 1], pi/2);
+%! srf  = nrbkntins (srf, {0.3, 0.6});
+%! srf2 = nrbreverse (srf, 1);
+%! knt{1} = sort(1-srf2.knots{1}); knt{2} = srf2.knots{2};
+%! assert (srf.knots, knt, 1e-15)
+%! assert (srf.coefs, srf2.coefs(:,end:-1:1,:))
+%! srf2 = nrbreverse (srf, 2);
+%! knt{1} = srf2.knots{1}; knt{2} = sort(1-srf2.knots{2});
+%! assert (srf.knots, knt, 1e-15)
+%! assert (srf.coefs, srf2.coefs(:,:,end:-1:1))
--- a/extra/nurbs/inst/nrbtransp.m	Mon Sep 01 15:36:45 2014 +0000
+++ b/extra/nurbs/inst/nrbtransp.m	Mon Sep 01 16:15:19 2014 +0000
@@ -52,4 +52,12 @@
 %! srf.coefs(3,:,:) = srf.coefs(3,:,:) + 10;
 %! srf = nrbtransp(srf);
 %! nrbplot(srf,[20 5]);
-%! hold off
\ No newline at end of file
+%! hold off
+
+%!test
+%! srf  = nrbrevolve(nrbline([1 0],[2 0]), [0 0 0], [0 0 1], pi/2);
+%! srft = nrbtransp(srf);
+%! assert (srf.number, fliplr(srft.number));
+%! assert (srf.order, fliplr(srft.order));
+%! assert (srf.knots, fliplr(srft.knots));
+%! assert (srf.coefs, permute(srft.coefs, [1 3 2]));
\ No newline at end of file