Skip to content

Commit b309d5e

Browse files
committed
MNT: unit vector edge case check in flight.py
- MNT: perp_axis singularity value error implemented to handle edge case for perp_axis being parallel to body axis in weathercocking model of 3 dof.
1 parent 90acba7 commit b309d5e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

rocketpy/simulation/flight.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,6 +1976,12 @@ def u_dot_generalized_3dof(self, t, u, post_processing=False):
19761976
# If parallel, use y axis
19771977
y_axis = Vector([0.0, 1.0, 0.0])
19781978
perp_axis = body_z_inertial ^ y_axis
1979+
if abs(perp_axis) < 1e-6:
1980+
# If still parallel, raise an error or choose a default axis
1981+
raise ValueError(
1982+
"Cannot determine a valid rotation axis: "
1983+
"body_z_inertial is parallel to both x and y axes."
1984+
)
19791985
rotation_axis = perp_axis.unit_vector
19801986
# 180 degree rotation: sin(angle) = 1
19811987
omega_mag = self.weathercock_coeff * 1.0

0 commit comments

Comments
 (0)