- Home /
Camera viewport transformation from one world to the rotated world.
Hi. We are working on a viewport based 360 video streaming service and faced a difficult problem, perhaps called as the change of basis problem.
Assuming a user is watching at a point (red dot in the figure) where the main camera's Euler angles are (20, 20, 0) in pitch, yaw, and roll angles in the original world space of which Euler angles are (0, 0, 0).
Owing to the viewport based service issue, we rotated the original world to (-20, 0, 0) angles and we want to know how the user can have the same viewport in the new world, meaning exactly watching the red sun in the middle. So, here in the rotated world, what will be the Euler angles of the headset? is our question.
We used Quaternion.euler function to rotate the headset angle but it didn't work as we expected. Ex) (-20, 0, 0).
This problem seems to be calculating Euler angles of an object from XYZ coordinate world to rotated XYZ coordinate world. Any suggestions? Thanks.
Answer by Glurth · May 12, 2018 at 04:26 PM
I would combine the two Euler Angles as Quaternions. E.g.
Quaternion camRotation = Quaternion.Euler(20,20,0);
Quaternion worldRotation = Quaternion.Euler(-20,0,0);
Quaternion result= worldRotation * camRotation; //Note: order is important when multiplying quaternions! (and I might have it backwards)
Vector3 resultEulers = result.eulerAngles;
Thank you so much. Yes. It was the problem of the order! :)
Your answer
Follow this Question
Related Questions
How to get Angle float of specific axis.(Turret clamping related). 2 Answers
c# modify only one axis of a quaternion 2 Answers
Use a single rotation axis of a freely rotating object 1 Answer
How do you smoothly transition/Lerp into a new rotation? 3 Answers
Change rotation of an object based on an HTC Vive Controller 1 Answer