| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Math::3Space; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.008'; # VERSION |
|
4
|
|
|
|
|
|
|
# ABSTRACT: 3D Coordinate math with an intuitive cross-space mapping API |
|
5
|
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
1624365
|
use strict; |
|
|
8
|
|
|
|
|
19
|
|
|
|
8
|
|
|
|
|
359
|
|
|
7
|
8
|
|
|
8
|
|
90
|
use warnings; |
|
|
8
|
|
|
|
|
19
|
|
|
|
8
|
|
|
|
|
449
|
|
|
8
|
8
|
|
|
8
|
|
49
|
use Carp; |
|
|
8
|
|
|
|
|
19
|
|
|
|
8
|
|
|
|
|
1969
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require XSLoader; |
|
11
|
|
|
|
|
|
|
XSLoader::load('Math::3Space', $Math::3Space::VERSION); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use overload '""' => sub { |
|
14
|
1
|
|
|
1
|
|
906
|
my @vecs = map [$_[0]->$_->xyz], qw(xv yv zv origin); |
|
15
|
1
|
|
|
|
|
33
|
"[\n" . join('', map " [@$_]\n", @vecs) . "]\n"; |
|
16
|
8
|
|
|
8
|
|
72
|
}; |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
127
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
{ package Math::3Space::Exports; |
|
20
|
8
|
|
|
8
|
|
6396
|
use Exporter::Extensible -exporter_setup => 1; |
|
|
8
|
|
|
|
|
83384
|
|
|
|
8
|
|
|
|
|
98
|
|
|
21
|
|
|
|
|
|
|
require Math::3Space::Vector; |
|
22
|
|
|
|
|
|
|
require Math::3Space::Projection; |
|
23
|
|
|
|
|
|
|
*vec3= *Math::3Space::Vector::vec3; |
|
24
|
|
|
|
|
|
|
*space= *Math::3Space::space; |
|
25
|
|
|
|
|
|
|
*frustum= *frustum_projection= *Math::3Space::Projection::_frustum; |
|
26
|
|
|
|
|
|
|
*perspective= *perspective_projection= *Math::3Space::Projection::_perspective; |
|
27
|
|
|
|
|
|
|
export qw( vec3 space frustum frustum_projection perspective perspective_projection ); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
7
|
|
|
7
|
|
918
|
sub import { shift; Math::3Space::Exports->import_into(scalar(caller), @_) } |
|
|
7
|
|
|
|
|
84
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
9
|
50
|
|
9
|
1
|
584645
|
sub parent { croak "read-only attribute" if @_ > 1; $_[0]{parent} } |
|
|
9
|
|
|
|
|
67
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Used by XS to avoid linking directly to PDL. The XS can call out to this perl method to |
|
34
|
|
|
|
|
|
|
# perform the PDL operations of vector subtraction, matrix multiplication, and vector addition, |
|
35
|
|
|
|
|
|
|
# all of which are overloaded operators and would be tedious to call from XS. |
|
36
|
|
|
|
|
|
|
# One single call to this method can operate in parallel on an ndarray of vectors, thanks to |
|
37
|
|
|
|
|
|
|
# PDL's broadcasting system, so this only gets called once per call to 'project_inplace'. |
|
38
|
|
|
|
|
|
|
sub _pdl_project_inplace { |
|
39
|
0
|
0
|
|
0
|
|
|
$_[0] -= $_[1] if defined $_[1]; |
|
40
|
0
|
|
|
|
|
|
$_[0] .= $_[0] x $_[2]; |
|
41
|
0
|
0
|
|
|
|
|
$_[0] += $_[3] if defined $_[3]; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |