Files
AIO_3D_Print_Local_Screen/refer/test_rot.py
2026-05-14 20:21:16 +08:00

26 lines
566 B
Python

import numpy as np
import math
rx = math.radians(-60.0)
rz = math.radians(45.0)
cosX, sinX = math.cos(rx), math.sin(rx)
cosZ, sinZ = math.cos(rz), math.sin(rz)
# Original code rotation matrix
rot = np.array([
[cosZ, -sinZ*cosX, sinZ*sinX, 0],
[sinZ, cosZ*cosX, -cosZ*sinX, 0],
[0, sinX, cosX, 0],
[0, 0, 0, 1]
])
print("Original rot:\\n", rot)
# Correct orbit Rx @ Rz
rot_correct = np.array([
[cosZ, -sinZ, 0, 0],
[cosX*sinZ, cosX*cosZ, -sinX, 0],
[sinX*sinZ, sinX*cosZ, cosX, 0],
[0, 0, 0, 1]
])
print("Rx @ Rz:\\n", rot_correct)