line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HackaMol::X::NERF; |
2
|
|
|
|
|
|
|
# ABSTRACT: Natural extension reference frame implementation for molecular building |
3
|
|
|
|
|
|
|
$HackaMol::X::NERF::VERSION = '0.003'; |
4
|
1
|
|
|
1
|
|
16084
|
use 5.008; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
1
|
|
|
1
|
|
408
|
use Moo; |
|
1
|
|
|
|
|
10707
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
1720
|
use Math::Vector::Real; |
|
1
|
|
|
|
|
12317
|
|
|
1
|
|
|
|
|
46
|
|
7
|
1
|
|
|
1
|
|
1379
|
use Math::Trig; |
|
1
|
|
|
|
|
17788
|
|
|
1
|
|
|
|
|
565
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $orig = V(0,0,0); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub init { |
12
|
|
|
|
|
|
|
# adding the first vector |
13
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
14
|
0
|
0
|
|
|
|
|
if (@_ == 3){ |
15
|
0
|
|
|
|
|
|
return V(@_); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
else { |
18
|
0
|
|
|
|
|
|
return $orig; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub extend_a { |
24
|
|
|
|
|
|
|
#allow the use of optvec to give control over the addition |
25
|
0
|
|
|
0
|
1
|
|
my ($self, $a, $R, $optvec) = @_; |
26
|
0
|
0
|
|
|
|
|
$optvec = V(1,0,0) unless defined($optvec); |
27
|
0
|
|
|
|
|
|
return ($a + $R*$optvec->versor); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub extend_ab { |
31
|
0
|
|
|
0
|
1
|
|
my ($self,$a,$b,$R,$ang) = @_; |
32
|
0
|
|
|
|
|
|
$ang = deg2rad(180-$ang); |
33
|
0
|
|
|
|
|
|
my ($ba, $j, $k) = ($b-$a)->rotation_base_3d; |
34
|
0
|
|
|
|
|
|
my $c = $b+$ba*$R; |
35
|
0
|
|
|
|
|
|
$c = $j->rotate_3d($ang, $c-$b) + $b; |
36
|
0
|
|
|
|
|
|
return ($c); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub extend_abc { |
40
|
0
|
|
|
0
|
1
|
|
my ($self,$a,$b,$c,$R,$ang,$tors) = @_; |
41
|
0
|
|
|
|
|
|
$ang = deg2rad(180-$ang); |
42
|
0
|
|
|
|
|
|
$tors = deg2rad($tors); |
43
|
0
|
|
|
|
|
|
my $cang = cos($ang); |
44
|
0
|
|
|
|
|
|
my $sang = sin($ang); |
45
|
0
|
|
|
|
|
|
my $ctor = cos($tors); |
46
|
0
|
|
|
|
|
|
my $stor = sin($tors); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $bc = ($c-$b)->versor; |
49
|
0
|
|
|
|
|
|
my $n = (($b-$a) x $bc)->versor; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $D = $R*($bc*$cang + ($n x $bc)*$sang*$ctor + $n*$sang*$stor) + $c; |
52
|
0
|
|
|
|
|
|
return $D; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |