line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HackaMol::X::NERF; |
2
|
|
|
|
|
|
|
# ABSTRACT: simple implementation of natural extension reference frame |
3
|
1
|
|
|
1
|
|
12376
|
use Moo; |
|
1
|
|
|
|
|
8626
|
|
|
1
|
|
|
|
|
4
|
|
4
|
1
|
|
|
1
|
|
1126
|
use Math::Vector::Real; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Math::Trig; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# extend system by 1 atom. |
8
|
|
|
|
|
|
|
# ABC to ABCD |
9
|
|
|
|
|
|
|
sub ext { |
10
|
|
|
|
|
|
|
my $self = shift; |
11
|
|
|
|
|
|
|
my $orig = V(0,0,0); |
12
|
|
|
|
|
|
|
$orig = V(@_) if @_ == 3; |
13
|
|
|
|
|
|
|
return $orig; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub ext_a { |
17
|
|
|
|
|
|
|
my ($self,$a, $R,$optvec) = @_; |
18
|
|
|
|
|
|
|
$optvec = V(1,0,0) unless defined($optvec); |
19
|
|
|
|
|
|
|
return ($a + $R*$optvec); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub ext_ab { |
23
|
|
|
|
|
|
|
my ($self,$a,$b,$R,$ang) = @_; |
24
|
|
|
|
|
|
|
$ang = deg2rad(180-$ang); |
25
|
|
|
|
|
|
|
my ($ba, $j, $k) = ($b-$a)->rotation_base_3d; |
26
|
|
|
|
|
|
|
my $c = $b+$ba*$R; |
27
|
|
|
|
|
|
|
#print abs($c-$b) . "\n"; |
28
|
|
|
|
|
|
|
$c = $j->rotate_3d($ang, $c-$b) + $b; |
29
|
|
|
|
|
|
|
#print abs($c-$b) . "\n"; |
30
|
|
|
|
|
|
|
return ($c); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub ext_abc { |
34
|
|
|
|
|
|
|
my ($self,$a,$b,$c,$R,$ang,$tors) = @_; |
35
|
|
|
|
|
|
|
$ang = deg2rad(180-$ang); |
36
|
|
|
|
|
|
|
$tors = deg2rad($tors); |
37
|
|
|
|
|
|
|
my $cang = cos($ang); |
38
|
|
|
|
|
|
|
my $sang = sin($ang); |
39
|
|
|
|
|
|
|
my $ctor = cos($tors); |
40
|
|
|
|
|
|
|
my $stor = sin($tors); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $bc = ($c-$b)->versor; |
43
|
|
|
|
|
|
|
my $n = (($b-$a) x $bc)->versor; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
my $D = $R*($bc*$cang + ($n x $bc)*$sang*$ctor + $n*$sang*$stor) + $c; |
46
|
|
|
|
|
|
|
return $D; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |