- 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

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.