get Rotation

Hello guys,
its sounds simple but i tried everything to get the 1:1 Camera Rotation from the Main Camera which is shown in the inspector in Unity when the device is connected with ARRemoteConnection.

You now that the values from the main camera transform rotation are changing when the device is moving in the range from -180 to 180 (which you can see in the inspector on the main camera when device is connected). But I don’t get this exact values. I tried:

m_camera.transform.rotation
m_camera.transform.rotation.eulerAngles
m_camera.transform.localRotation
m_camera.transform.localRotation.eulerAngles

but the x-value goes from
0 to 90, 90 to 0, 360 to 280, 280 to 360 (this functions give me an other value than the camera have !!)

I need the solution really. It would be nice if you say to me how do you want to get this because I tried some hours!

Thank you

kind regards

have a look at https://docs.unity3d.com/Manual/Transforms.html and Unity - Manual: Rotation and orientation in Unity

So I try it again:
ARKit-Unity sets the Quaternion to the Camera:

  • m_camera.transform.localRotation = UnityARMatrixOps.GetRotation (matrix);
  • camera gets a Quaternion and shows us that in Euler-Angles (values from 0 to 180; -180 to 0) in the Inspector*

Now we can try to get this Euler-Angles and it will never work…:

  • m_camera.transform.rotation or m_camera.transform.localRotation
    Here we get just Quaternion-Values: 0.5f = 60°; 1.0f = 180°, …

  • m_camera.transform.rotation.eulerAngles.x or m_camera.transform.localRotation.eulerAngles.x
    Here we get Quaternion-Values converted in euler-angles (quaternion.eulerAngles) and we get:
    0 to 90; 90 to 0; 360 to 280; 280 to 360 … this aren’t the values from 0 to 180; -180 to 0) shown in the Inspector

I didn’t find a possible way to get values which I can use and that are Values from 0 to 365 for every axis or the inspector values from 0 to 180; -180 to 0 which we can convert into 0 to 365…

Can anyone help me out here??

From that page: “In Unity all Game Object rotations are stored internally as Quaternions, because the benefits outweigh the limitations.”

What you’re seeing is different Euler representations of the actual rotation. For you to work properly with rotations, you should understand quaternions and use them to do your manipulations.

Yes. Unity use intern Quaternions. ARKit set a Quaternion to the Camera. The Camera show us that quaternion values in the Inspector as Euler angles. For that Unity must convert this Quaternion in Euler-Angles to show us the values from 0 to 180; -180 to 0 for x y z in the rotation in the inspector.

If I do convert the same Quaternion (which is set to the camera) as Euler Angles (with Unity Quaternion.eulerAngles functions) we get other Euler angle Values than in the Inspector:
values from 0 to 90; 90 to 0; 360 to 280; 280 to 360 for the x-axis.

So me and anybody else can’t use any unity function to get the right values because it don’t work.

What are you trying to do? Why do you need to match up the values?

this values are really important for me and for my project. Thats a reason why I ask here. I tried everything to match up this values but really nothing worked… maybe I think this is a unity problem because it make no sense that I can’t get the values.