Skip to content Skip to sidebar Skip to footer

Control Of Orthographic Camera Position And Orientation From Euler Angles

Attempting to control orthorgraphic camera position (x,y,z) and up vector (top of camera) from euler angles. I have a real world device with an IMU that outputs rotation along eac

Solution 1:

If your Euler angles represent an absolute rotation, you can calculate a rotation matrix R. How you do this depends on the definition of the Euler angles, which should be described in the documentation. It might be:

R = rotateY(yaw) * rotateX(pitch) * rotateZ(roll)

Again, this is just an example. The correct formula depends on the order of Euler angles and their interpretation.

The camera's model matrix can then be calculated as:

cam = translation(target) * R * translation(0, 0, radius)

(or -radius for left-handed coordinate systems). translation() calculates a translation matrix.

The intuition behind this is that you move your camera to the target, then rotate it according to R, and then move it back by radius.

If you have this matrix, the camera's up-vector will be its second column, the eye-vector will be its fourth column. If you just need a view-matrix, use cam's inverse.

Note: The explanations above assume that vectors are treated as column vectors. If they are treated as row vectors (e.g. common in DirectX), the calculations have to be adapted accordingly.

Post a Comment for "Control Of Orthographic Camera Position And Orientation From Euler Angles"