0

I have a 3D camera that has animated euler rotation applied to it. I would need to duplicate this camera but only keep the horizontal rotation of it.

Here is an example: https://youtu.be/x5gtPFnv2jU

As you can see the center object only rotates on its Z axis while the background has a 3D camera rotating on all XYZ. I made it in Fusion (compositing software with 3D capability) using it's internal look-at function and a bunch of more stuff but I would like to just make a script that converts the camera to the wanted kind of rotation.

Any how, it doesn't matter if I need to convert the rotation to quaternions or a rotation matrix to make this work.

In my research I found https://eater.net/quaternions/video/intro where he goes through quaternions. In the example you can toggle the angle form of the quaternions:

quaternion rotation angle form

And the value now inside the cos and sin function is the one I'm after! I haven't found any function out there that conerts a quaternion to the values you get after enabeling angle form.

1 Answers1

0

unit quaternions for rotations are of form

(xi + yj + zk + w)

Usually in code, a quaternion is stored using 4 floating-point values, such as (x, y, z, w).

Here x, y, z represents the unit rotation axis vector multiplied by sin(theta/2) and w is cos(theta/2).

So if your rotation quaternion is normalized, then acos(w) will give you theta/2, thus multiplying this value by 2, you will get the rotation angle the quaternion represents (in radians)

In summary,

float theta = acos(quat.w) * 2.0f;