Skip to content

Commit ad37e8c

Browse files
committed
add tests for QuaterControllers eg ArcCone
1 parent ce45b2b commit ad37e8c

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- non-trivial tests added
2+
13
2.100 2025-01-16
24
- adjust MathGraph and Labels so Debian packaging is happy
35

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ lib/PDL/Graphics/VRML/Protos.pm
4343
Makefile.PL
4444
MANIFEST This list of files
4545
MANIFEST.SKIP
46+
t/arcball.t
4647
t/opengl.t

lib/PDL/Graphics/TriD/ArcBall.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
package PDL::Graphics::TriD::QuaterController;
1313
use strict;
1414
use warnings;
15+
use PDL::Graphics::TriD::Quaternion;
1516
use base qw(PDL::Graphics::TriD::ButtonControl);
1617
use fields qw /Inv Quat/;
1718

t/arcball.t

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
use strict;
2+
use warnings;
3+
use Test::More;
4+
5+
use PDL::Graphics::TriD::ArcBall;
6+
use PDL::LiteF;
7+
use Test::PDL;
8+
{package FakeWindow; sub new {bless {}} sub add_resizecommand {} }
9+
10+
sub is_qua {
11+
local $Test::Builder::Level = $Test::Builder::Level + 1;
12+
my ($got, $exp) = map PDL->pdl(@$_), @_;
13+
is_pdl $got, $exp;
14+
}
15+
16+
my $win = FakeWindow->new;
17+
18+
my $arcball = PDL::Graphics::TriD::ArcBall->new($win);
19+
isa_ok $arcball, 'PDL::Graphics::TriD::ArcBall';
20+
$arcball->set_wh(100,100);
21+
is_qua $arcball->xy2qua(25,25), [0,-0.5,0.5,0.707106];
22+
is_qua $arcball->xy2qua(25,50), [0,-0.5,0,0.866025];
23+
is_qua $arcball->xy2qua(25,75), [0,-0.5,-0.5,0.707106];
24+
is_qua $arcball->xy2qua(75,25), [0,0.5,0.5,0.707106];
25+
is_qua $arcball->xy2qua(75,50), [0,0.5,0,0.866025];
26+
is_qua $arcball->xy2qua(75,75), [0,0.5,-0.5,0.707106];
27+
28+
my $arccone = PDL::Graphics::TriD::ArcCone->new($win);
29+
isa_ok $arccone, 'PDL::Graphics::TriD::ArcCone';
30+
$arccone->set_wh(100,100);
31+
is_qua $arccone->xy2qua(25,25), [0,-0.653281,0.653281,0.382683];
32+
is_qua $arccone->xy2qua(25,50), [0,-0.707106,0,0.707106];
33+
is_qua $arccone->xy2qua(25,75), [0,-0.653281,-0.653281,0.382683];
34+
is_qua $arccone->xy2qua(75,25), [0,0.653281,0.653281,0.382683];
35+
is_qua $arccone->xy2qua(75,50), [0,0.707106,0,0.707106];
36+
is_qua $arccone->xy2qua(75,75), [0,0.653281,-0.653281,0.382683];
37+
38+
my $arcbowl = PDL::Graphics::TriD::ArcBowl->new($win);
39+
isa_ok $arcbowl, 'PDL::Graphics::TriD::ArcBowl';
40+
$arcbowl->set_wh(100,100);
41+
is_qua $arcbowl->xy2qua(25,25), [0,-0.598883,0.598883,0.531673];
42+
is_qua $arcbowl->xy2qua(25,50), [0,-0.577389,0,0.816468];
43+
is_qua $arcbowl->xy2qua(25,25), [0,-0.598883,0.598883,0.531673];
44+
is_qua $arcbowl->xy2qua(75,25), [0,0.598883,0.598883,0.531673];
45+
is_qua $arcbowl->xy2qua(75,50), [0,0.577389,0,0.816468];
46+
is_qua $arcbowl->xy2qua(75,75), [0,0.598883,-0.598883,0.531673];
47+
48+
done_testing;

0 commit comments

Comments
 (0)