Reputation: 4142
I'm attempting to make an first-person program in OpenGL.
I've used the GLM library for the calculations, which only has a lookAt()
function for a View Matrix. However, the function parameters take the location of the camera and the x, y, z
coordinates of what it's looking at.
I want to change pitch, yaw, roll into x, y, z
. However, there doesn't seem to be any equations on the internet.
Roll is ignored, but how can using just pitch and yaw give you x, y, z
coordinates?
0, 0
returns 0, 0, 1
0, pi
returns 0, 1, 0
pi, 0
returns 1, 0, 0
etc.Can anyone help with the calculations for all values 0 - 2pi
?
Upvotes: 0
Views: 442
Reputation: 162164
Build the rotation matrices for yaw, pitch and roll, and multiply them. The resulting product is a matrix with the rotated coordinate system base vectors as its columns. However the vectors are not guaranteed to be orthogonal. In fact it may happen that two or all three of them become colinear due to an effect called gimbal lock. Gimbal lock is also the reason why you shouldn't use Euler rotations at all.
Upvotes: 1