<jupyter_start><jupyter_text>System Equations  Declare System Variables<jupyter_code># Body angle
phi, theta, psi = symbols('phi theta psi')

# Rotation rates in body frame
dPhi, dTheta, dPsi = symbols('dPhi, dTheta, dPsi')

# Linear velocity in inertial frame
p, q, r = symbols('p q r')<jupyter_output><empty_output><jupyter_text>Derive Newton-Euler Equations  Rotation Matrix from Body Frame to Inertial Frame<jupyter_code># Rotate around the X-axis
Rx = Matrix([[1, 0, 0], [0, cos(phi), -1*sin(phi)], [0, sin(phi), cos(phi)]])

# Rotate around the Y-axis
Ry = Matrix([[cos(theta), 0, sin(theta)], [0, 1, 0], [-1*sin(theta), 0, cos(theta)]])

# Rotate around the Z-axis
Rz = Matrix([[cos(psi), -1*sin(psi), 0], [sin(psi), cos(psi), 0], [0, 0, 1]])

# Rotation matrix from the body frame to the inertial frame
R = Rz*Ry*Rx
R<jupyter_output><empty_output><jupyter_text>Transformation Matrix for Angular Velocity<jupyter_code># Inertial frame to body frame
dEta = Matrix([[1, sin(phi)*tan(theta), cos(phi)*tan(theta)], [0, cos(phi), -1*sin(phi)], [0, sin(phi)/cos(theta), cos(phi)/cos(theta)]]) * Matrix([p, q, r])
V = Matrix([[1, 0, -1*sin(theta)], [0, cos(phi), cos(theta)*sin(phi)], [0, -1*sin(phi), cos(theta)*cos(phi)]])*Matrix([dPhi, dTheta, dPsi])

print(theta)
print(Rx)
Rx<jupyter_output>theta
Matrix([[1, 0, 0], [0, cos(phi), -sin(phi)], [0, sin(phi), cos(phi)]])
{'fraction_non_alphanumeric': 0.20262390670553937, 'fraction_numerical': 0.024052478134110787, 'mean_word_length': 6.543956043956044, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '74166', 'license': 'MIT', 'n_tokens_mistral': 575, 'n_tokens_neox': 543, 'n_words': 146, 'path': 'sandbox/DronePhysics.ipynb', 'repo_name': 'brandonbraun653/Valkyrie', 'size': '1372'}