Skip to content

Commit 2d755a4

Browse files
committed
Correction of the missing function that caused errors
1 parent 9624374 commit 2d755a4

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

rocketpy/tools.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,33 @@ def wrapper(*args, **kwargs):
10791079
return decorator
10801080

10811081

1082+
def parallel_axis_theorem_from_com(com_inertia_moment, mass, distance):
1083+
"""Calculates the moment of inertia of a object relative to a new axis using
1084+
the parallel axis theorem. The new axis is parallel to and at a distance
1085+
'distance' from the original axis, which *must* passes through the object's
1086+
center of mass.
1087+
1088+
Parameters
1089+
----------
1090+
com_inertia_moment : float
1091+
Moment of inertia relative to the center of mass of the object.
1092+
mass : float
1093+
Mass of the object.
1094+
distance : float
1095+
Perpendicular distance between the original and new axis.
1096+
1097+
Returns
1098+
-------
1099+
float
1100+
Moment of inertia relative to the new axis.
1101+
1102+
References
1103+
----------
1104+
https://en.wikipedia.org/wiki/Parallel_axis_theorem
1105+
"""
1106+
return com_inertia_moment + mass * distance**2
1107+
1108+
10821109
def _pat_dynamic_helper(com_inertia_moment, mass, distance_vec_3d, axes_term_lambda):
10831110
"Local import to break circular dependency with mathutils.function"
10841111
from rocketpy.mathutils.function import (
@@ -1095,11 +1122,9 @@ def _pat_dynamic_helper(com_inertia_moment, mass, distance_vec_3d, axes_term_lam
10951122
)
10961123

10971124
def get_val(arg, t):
1098-
10991125
return arg(t) if isinstance(arg, Function) else arg
11001126

11011127
if not is_dynamic:
1102-
11031128
d_vec = Vector(distance_vec_3d)
11041129
mass_term = mass * axes_term_lambda(d_vec)
11051130
return com_inertia_moment + mass_term
@@ -1134,11 +1159,9 @@ def _pat_dynamic_product_helper(
11341159
)
11351160

11361161
def get_val(arg, t):
1137-
11381162
return arg(t) if isinstance(arg, Function) else arg
11391163

11401164
if not is_dynamic:
1141-
11421165
d_vec = Vector(distance_vec_3d)
11431166
mass_term = mass * product_term_lambda(d_vec)
11441167
return com_inertia_product + mass_term
@@ -1155,43 +1178,43 @@ def new_source(t):
11551178
return Function(new_source, inputs="t", outputs="Inertia (kg*m^2)")
11561179

11571180

1181+
# pylint: disable=invalid-name
11581182
def parallel_axis_theorem_I11(com_inertia_moment, mass, distance_vec_3d):
1159-
11601183
return _pat_dynamic_helper(
11611184
com_inertia_moment, mass, distance_vec_3d, lambda d_vec: d_vec.y**2 + d_vec.z**2
11621185
)
11631186

11641187

1188+
# pylint: disable=invalid-name
11651189
def parallel_axis_theorem_I22(com_inertia_moment, mass, distance_vec_3d):
1166-
11671190
return _pat_dynamic_helper(
11681191
com_inertia_moment, mass, distance_vec_3d, lambda d_vec: d_vec.x**2 + d_vec.z**2
11691192
)
11701193

11711194

1195+
# pylint: disable=invalid-name
11721196
def parallel_axis_theorem_I33(com_inertia_moment, mass, distance_vec_3d):
1173-
11741197
return _pat_dynamic_helper(
11751198
com_inertia_moment, mass, distance_vec_3d, lambda d_vec: d_vec.x**2 + d_vec.y**2
11761199
)
11771200

11781201

1202+
# pylint: disable=invalid-name
11791203
def parallel_axis_theorem_I12(com_inertia_product, mass, distance_vec_3d):
1180-
11811204
return _pat_dynamic_product_helper(
11821205
com_inertia_product, mass, distance_vec_3d, lambda d_vec: d_vec.x * d_vec.y
11831206
)
11841207

11851208

1209+
# pylint: disable=invalid-name
11861210
def parallel_axis_theorem_I13(com_inertia_product, mass, distance_vec_3d):
1187-
11881211
return _pat_dynamic_product_helper(
11891212
com_inertia_product, mass, distance_vec_3d, lambda d_vec: d_vec.x * d_vec.z
11901213
)
11911214

11921215

1216+
# pylint: disable=invalid-name
11931217
def parallel_axis_theorem_I23(com_inertia_product, mass, distance_vec_3d):
1194-
11951218
return _pat_dynamic_product_helper(
11961219
com_inertia_product, mass, distance_vec_3d, lambda d_vec: d_vec.y * d_vec.z
11971220
)

0 commit comments

Comments
 (0)