Skip to content

Commit b1befac

Browse files
committed
move VRML stuff out of ::Quaternion into ::VRML
1 parent 111f8a4 commit b1befac

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

lib/PDL/Graphics/TriD/Quaternion.pm

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,6 @@ sub copy {
6060
PDL::Graphics::TriD::Quaternion->new(@{$_[0]});
6161
}
6262

63-
sub new_vrmlrot {
64-
my($type,$x,$y,$z,$c) = @_;
65-
my $l = sqrt($x**2+$y**2+$z**2);
66-
my $this = bless [cos($c/2),map {sin($c/2)*$_/$l} $x,$y,$z],$type;
67-
$this->normalise;
68-
}
69-
70-
sub to_vrmlrot {
71-
my($this) = @_;
72-
my $d = POSIX::acos($this->[0]);
73-
if(abs($d) < 0.0000001) {
74-
return [0,0,1,0];
75-
}
76-
return [(map {$_/sin($d)} @{$this}[1..3]),2*$d];
77-
}
78-
7963
sub multiply {
8064
my($this,$with) = @_;
8165
return PDL::Graphics::TriD::Quaternion->new(

lib/PDL/Graphics/TriD/VRML.pm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,22 @@ sub PDL::Graphics::TriD::Object::tovrml {
718718
[map {$_->tovrml()} @{$this->{Objects}}]);
719719
}
720720

721+
sub PDL::Graphics::TriD::Quaternion::new_vrmlrot {
722+
my($type,$x,$y,$z,$c) = @_;
723+
my $l = sqrt($x**2+$y**2+$z**2);
724+
my $this = bless [cos($c/2),map {sin($c/2)*$_/$l} $x,$y,$z],$type;
725+
$this->normalise;
726+
}
727+
728+
sub PDL::Graphics::TriD::Quaternion::to_vrmlrot {
729+
my($this) = @_;
730+
my $d = POSIX::acos($this->[0]);
731+
if (abs($d) < 0.0000001) {
732+
return [0,0,1,0];
733+
}
734+
return [(map {$_/sin($d)} @{$this}[1..3]),2*$d];
735+
}
736+
721737
1;
722738

723739
=head1 BUGS

0 commit comments

Comments
 (0)