add smargon math
CI for mx_bec / test (push) Failing after 51s

This commit is contained in:
perl_d committed 2026-11-11 14:09:25 +01:00
1 parent 9c4d7566cf
commit 78fe7ae11a
1 file changed
+37
+37
View File
@@ -0,0 +1,37 @@
import numpy as np
from aarecommon.math.coordinate import Coordinate
def smargon_nudge(
phi_deg: float, chi_deg: float, omega_deg: float, nudge_vector: Coordinate
) -> Coordinate:
"""Translate a relative movement of the smargon from lab frame to smargon frame.
Add the result of this to the smargon's current position to get the new position."""
phi = np.radians(np.around(phi_deg, decimals=1))
chi = np.radians(np.around(chi_deg, decimals=1))
omega = np.radians(np.around(omega_deg, decimals=1))
offset = Coordinate()
co = np.cos(omega)
so = np.sin(omega)
cp = np.cos(phi)
sp = np.sin(phi)
cc = np.cos(chi)
sc = np.sin(chi)
offset.x = (
-nudge_vector.z * co * sp
- nudge_vector.y * so * sp
+ nudge_vector.x * cp * sc
- nudge_vector.y * co * cc * cp
+ nudge_vector.z * so * cc * cp
)
offset.y = (
-nudge_vector.z * co * cp
- nudge_vector.y * so * cp
- nudge_vector.x * sc * sp
+ nudge_vector.y * co * cc * sp
- nudge_vector.z * so * cc * sp
)
offset.z = -nudge_vector.x * cc - nudge_vector.y * co * sc + nudge_vector.z * so * sc
return offset