From 103e99ba48fc0e8a6129c8f2f180a992e61dda53 Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Tue, 17 Feb 2026 20:47:15 +0000 Subject: [PATCH 1/2] perf: reusing identity matrix for performance, removed redundency --- opendis/RangeCoordinates.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/opendis/RangeCoordinates.py b/opendis/RangeCoordinates.py index 6d96fae..5fd7577 100644 --- a/opendis/RangeCoordinates.py +++ b/opendis/RangeCoordinates.py @@ -112,6 +112,10 @@ class GPS: wgs84 = WGS84() + _IDENTITY_3X3 = array([[1., 0., 0.], + [0., 1., 0.], + [0., 0., 1.]]) + def ecef2lla(self, ecef, tolerance=1e-9): """Convert Earth-centered, Earth-fixed coordinates to lat, lon, alt. Input: ecef - (x, y, z) in (m, m, m) @@ -516,8 +520,6 @@ def rotate_3x3(self, theta, normal_vec): the rotation. """ - n_v_t = normal_vec.transpose() - n_x = array([[ 0 , -normal_vec[2], normal_vec[1] ], [normal_vec[2] , 0 , -normal_vec[0]], [-normal_vec[1], normal_vec[0] , 0 ] @@ -525,11 +527,9 @@ def rotate_3x3(self, theta, normal_vec): ) - I = identity(3) - nnt = normal_vec * self.transpose(normal_vec) - return (1 - cos(theta)) * nnt + cos(theta) * I + sin(theta) * n_x + return (1 - cos(theta)) * nnt + cos(theta) * self._IDENTITY_3X3 + sin(theta) * n_x def transpose(self, arr): From 6ce5cb84c3f8bf577c283f259ebb9394d4fb5c69 Mon Sep 17 00:00:00 2001 From: Matt Robinson <58814711+mcrrobinson@users.noreply.github.com> Date: Wed, 18 Feb 2026 11:00:51 +0000 Subject: [PATCH 2/2] Apply suggestion from @leif81 Old habits die hard. Co-authored-by: Leif Gruenwoldt --- opendis/RangeCoordinates.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/opendis/RangeCoordinates.py b/opendis/RangeCoordinates.py index 5fd7577..4c9da54 100644 --- a/opendis/RangeCoordinates.py +++ b/opendis/RangeCoordinates.py @@ -112,9 +112,7 @@ class GPS: wgs84 = WGS84() - _IDENTITY_3X3 = array([[1., 0., 0.], - [0., 1., 0.], - [0., 0., 1.]]) + _IDENTITY_3X3 = identity(3) def ecef2lla(self, ecef, tolerance=1e-9): """Convert Earth-centered, Earth-fixed coordinates to lat, lon, alt.