Skip to content

Commit b5c8115

Browse files
committed
test normalise_as
1 parent e726702 commit b5c8115

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ MANIFEST This list of files
4141
MANIFEST.SKIP
4242
t/arcball.t
4343
t/graph.t
44+
t/object.t
4445
t/objects.t
4546
t/quaternion.t

lib/PDL/Graphics/TriD/Object.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use strict;
44
use warnings;
55
use Scalar::Util qw(weaken);
66
use Carp 'confess';
7+
use PDL::ImageND;
78

89
use fields qw(Objects IsValid ChangedSub Impl Options);
910

t/object.t

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use strict;
2+
use warnings;
3+
use PDL;
4+
use PDL::Graphics::TriD::Object;
5+
use Test::More;
6+
use Test::PDL;
7+
8+
my $o = PDL::Graphics::TriD::Object->new;
9+
eval { $o->normalise_as('', [pdl(1)]) };
10+
like $@, qr/Must have 3 coordinates if no interpretation/;
11+
is_pdl $o->normalise_as('', [pdl(1), pdl(4), pdl(7)]), float(1,4,7);
12+
eval { $o->normalise_as('COLOR', pdl(1,4,7)) };
13+
like $@, qr/Given 1D ndarray as colour but no points to match/;
14+
15+
sub PDL::Graphics::TriD::Object::cdummies { $_[1]->dummy(1,$_[2]->getdim(1)); }
16+
is_pdl $o->normalise_as('COLOR', pdl(1,4,7), zeroes(2,4)), float('1 4 7; 1 4 7; 1 4 7; 1 4 7');
17+
18+
is_pdl $o->normalise_as('', [SURF2D=>pdl('1 4 7;5 8 9')]), float('
19+
[0 0 1; 1 0 4; 2 0 7]
20+
[0 1 5; 1 1 8; 2 1 9]
21+
');
22+
23+
is_pdl $o->normalise_as('', [LINE=>pdl('1 4 7'), pdl('5 8 9')]), float('
24+
1 5 0; 4 8 1; 7 9 2
25+
');
26+
is_pdl $o->normalise_as('', [LINE=>pdl('1 4 7')]), float('
27+
0 1 0; 1 4 0; 2 7 0
28+
');
29+
30+
is_pdl $o->normalise_as('', [POLAR2D=>pdl('1 4 7;5 8 9')]), float('
31+
[0 0 1; 0 0 4; 0 0 7]
32+
[0 1 5; 0.000092 -1 8; -0.000185 1 9]
33+
');
34+
35+
done_testing;

0 commit comments

Comments
 (0)