How to convert camera projectionMatrix to XY coordinates?


Is there anyway in Three JS or in general to convert a camera projectionMatrix to xy rotation coordinates?

For example from this:
[0.6886721253395081, 0, 0, 0, 0, 0.7380335927009583, 0, 0, 0, 0, -1.0000666379928589, -0.2000066637992859, 0, 0, -1, 0]

To this:
[x: -11.9088342826715, y: 146.50703938883]

Thank You!

A projection matrix is unrelated to rotations in 3D. So what you are trying to do is mathematically not plausible.

Besides, Euler rotation values consist of XYZ values and not just XY.

I’m sorry for the misunderstanding, what I’m trying to achieve in the end is to convert the camera XYZ rotation values into X and Y 360 degree rotation values. Is this possible?

You can use .setFromRotationMatrix to extract the rotational angles from a matrix. But orientation in 3D is defined by three angles (that’s a mathematical fact), so the method above you will give you three angles. You must also have the correct order (Three.js has a method to reorder angles), because the rotation values depend on the order of rotations. And only after this, you can pick the two angles (I assume you are interested in alpha and beta) and ignore the third angle (gamma):

Also, @Mugen87 is perfectly right. Rotational data are not encoded in the projection matrix, so I assume you talk about the view matrix. My suggestion is just to calculate the angles with Math.atan2 using the camera coordinates and its target coordinates.