Fix all the rotation directions #2

Closed
opened 2026-08-02 17:58:34 -04:00 by cx40 · 0 comments
Owner

There are very likely inconsistencies in the signs and what I've documented in the comments. I just set the signs through trial and error until it worked.

Check them over and make sure they all adhere to the right hand rule (thumb points towards positive axis direction, curled fingers point towards positive rotation direction).

Relevant lines

Line 28 in f03d09a
# In 3D, the x-axis points to the right, the y-axis points up, and the z-axis points forward.

Lines 60 to 74 in f03d09a
rotation_matrix_yaw = np.array([
[np.cos(yaw), 0, np.sin(yaw)],
[0, 1, 0 ],
[-np.sin(yaw), 0, np.cos(yaw)]
])
rotation_matrix_pitch = np.array([
[1, 0, 0 ],
[0, np.cos(pitch), -np.sin(pitch)],
[0, np.sin(pitch), np.cos(pitch) ]
])
rotation_matrix_roll = np.array([
[np.cos(roll), np.sin(roll), 0],
[-np.sin(roll), np.cos(roll), 0],
[0, 0, 1]
])

Lines 137 to 149 in f03d09a
# Do logical updates here.
if key_is_down[pygame.K_LEFT]:
yaw -= delta_yaw
if key_is_down[pygame.K_RIGHT]:
yaw += delta_yaw
if key_is_down[pygame.K_UP]:
pitch += delta_pitch
if key_is_down[pygame.K_DOWN]:
pitch -= delta_pitch
if key_is_down[pygame.K_q]:
roll += delta_roll
if key_is_down[pygame.K_e]:
roll -= delta_roll

There are very likely inconsistencies in the signs and what I've documented in the comments. I just set the signs through trial and error until it worked. Check them over and make sure they all adhere to the right hand rule (thumb points towards positive axis direction, curled fingers point towards positive rotation direction). Relevant lines https://git.cx40.ca/cx40/panorama/src/commit/f03d09a406e8cd7ede6877461af2c61ad3866388/script.py#L28 https://git.cx40.ca/cx40/panorama/src/commit/f03d09a406e8cd7ede6877461af2c61ad3866388/script.py#L60-L74 https://git.cx40.ca/cx40/panorama/src/commit/f03d09a406e8cd7ede6877461af2c61ad3866388/script.py#L137-L149
cx40 referenced this issue from a commit 2026-08-03 10:20:29 -04:00
#2
cx40 closed this issue 2026-08-03 10:21:12 -04:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cx40/panorama#2
No description provided.