Skip to content

Commit 103e99b

Browse files
committed
perf: reusing identity matrix for performance, removed redundency
1 parent 10db1e4 commit 103e99b

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

opendis/RangeCoordinates.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ class GPS:
112112

113113
wgs84 = WGS84()
114114

115+
_IDENTITY_3X3 = array([[1., 0., 0.],
116+
[0., 1., 0.],
117+
[0., 0., 1.]])
118+
115119
def ecef2lla(self, ecef, tolerance=1e-9):
116120
"""Convert Earth-centered, Earth-fixed coordinates to lat, lon, alt.
117121
Input: ecef - (x, y, z) in (m, m, m)
@@ -516,20 +520,16 @@ def rotate_3x3(self, theta, normal_vec):
516520
the rotation.
517521
"""
518522

519-
n_v_t = normal_vec.transpose()
520-
521523
n_x = array([[ 0 , -normal_vec[2], normal_vec[1] ],
522524
[normal_vec[2] , 0 , -normal_vec[0]],
523525
[-normal_vec[1], normal_vec[0] , 0 ]
524526
]
525527
)
526528

527529

528-
I = identity(3)
529-
530530
nnt = normal_vec * self.transpose(normal_vec)
531531

532-
return (1 - cos(theta)) * nnt + cos(theta) * I + sin(theta) * n_x
532+
return (1 - cos(theta)) * nnt + cos(theta) * self._IDENTITY_3X3 + sin(theta) * n_x
533533

534534

535535
def transpose(self, arr):

0 commit comments

Comments
 (0)