# Rotation angles for the point cloud

**URL:** <https://community.stereolabs.com/t/rotation-angles-for-the-point-cloud/4768>\
**Category:** Python\
**Created:** [March 18, 2024, 12:55pm UTC](https://community.stereolabs.com/t/rotation-angles-for-the-point-cloud/4768 "2024-03-18T12:55:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![CristianViSa](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/c/85e7bf/32.png) [@CristianViSa](https://community.stereolabs.com/u/CristianViSa)\
**Post date:** [March 18, 2024, 12:55pm UTC](https://community.stereolabs.com/t/rotation-angles-for-the-point-cloud/4768/1 "2024-03-18T12:55:39Z")

</div>

Hi,

I have a ZED 2i camera from which i obtain my point clouds and images. However, sometimes, the camera inclinates for some external reasons.

I need the point clouds to be straightened in order to calculate slopes (purpose of the camera). I am struggling understanding the operations needed. In the doc, i can get the euler angles in format YZX, then i apply this rotation with this angles (but inversed) with numpy operations BUT the point cloud is not straightened up.

Then i realized i could use the pyzed to obtain the rotation matrix. But i just realized that if i inverse this matrix (transform.inverse) and I apply it to the point cloud it distorts, but if i dont reverse, the point cloud seems straightened. How is this possible? Should this rotation matrix be inverted?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mattrouss](https://community.stereolabs.com/user_avatar/community.stereolabs.com/mattrouss/32/2452_2.png) [@mattrouss](https://community.stereolabs.com/u/mattrouss)\
**Post date:** [March 19, 2024, 8:25am UTC](https://community.stereolabs.com/t/rotation-angles-for-the-point-cloud/4768/2 "2024-03-19T08:25:37Z")

</div>

Hi Cristian,

By default, the ZED SDK uses the IMU information to orient the camera with respect to the gravity vector. This behavior is controlled with the [PositionalTrackingParameters.set\_gravity\_as\_origin](https://www.stereolabs.com/docs/api/structsl_1_1PositionalTrackingParameters.html#abf134b0fc2e3327ef136197f7feafdfc) parameter. Can you try setting it to `false` and see if this fixes your orientation issue?

---

<div class="post-metadata">

**Author:** ![CristianViSa](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/c/85e7bf/32.png) [@CristianViSa](https://community.stereolabs.com/u/CristianViSa)\
**Post date:** [March 19, 2024, 3:05pm UTC](https://community.stereolabs.com/t/rotation-angles-for-the-point-cloud/4768/3 "2024-03-19T15:05:47Z")

</div>

Hi mattrouss, thanks for the response.

I have tried it and it keeps happening. I think this is a problem of identifying the correct angles of rotation and its axis.

I have realized that, WITH THE CAMERA IN THE SAME POSITION, using ZED\_Sensors\_Viewer Orientation i obtain angles of:  
X: - 1.5  
Y: + 1.7  
Z: + 40

However, with a recorded SVO file, the output of get\_euler\_angles() is as follows:  
( -1.5, -1.7, -40)

NOTE THE SIGNES, They are ALL INVERTED BUT ONE. And my guess is that The func returns the angles XYZ, NOT YZS As the doc says. And why are them inverted except one? The x axis?

---

<div class="post-metadata">

**Author:** ![mattrouss](https://community.stereolabs.com/user_avatar/community.stereolabs.com/mattrouss/32/2452_2.png) [@mattrouss](https://community.stereolabs.com/u/mattrouss)\
**Post date:** [March 19, 2024, 3:10pm UTC](https://community.stereolabs.com/t/rotation-angles-for-the-point-cloud/4768/4 "2024-03-19T15:10:31Z")

</div>

Hi @CristianViSa,

Please take a look at this documentation page: [Coordinate Frames - Stereolabs](https://www.stereolabs.com/docs/positional-tracking/coordinate-frames#selecting-a-coordinate-system)  
which explains the different coordinate frames of the ZED SDK. The sign difference is probably because ZED Sensor Viewer displays in a different coordinate frame than your sample. Please select the coordinate frame you are expecting.

---

<div class="post-metadata">

**Author:** ![CristianViSa](https://community.stereolabs.com/letter_avatar_proxy/v4/letter/c/85e7bf/32.png) [@CristianViSa](https://community.stereolabs.com/u/CristianViSa)\
**Post date:** [March 19, 2024, 3:14pm UTC](https://community.stereolabs.com/t/rotation-angles-for-the-point-cloud/4768/5 "2024-03-19T15:14:19Z")

</div>

I am using as default, Right Handed Y down.

So i am totally confused right now. What are the angles to straighten my cloud points using this coordinate frame?

The ones i obtain but inverted? So euler angles returns XYZ or YZX?

---

<div class="post-metadata">

**Author:** ![mattrouss](https://community.stereolabs.com/user_avatar/community.stereolabs.com/mattrouss/32/2452_2.png) [@mattrouss](https://community.stereolabs.com/u/mattrouss)\
**Post date:** [March 20, 2024, 3:42pm UTC](https://community.stereolabs.com/t/rotation-angles-for-the-point-cloud/4768/6 "2024-03-20T15:42:43Z")

</div>

The default coordinate frame in the SDK is COORDINATE\_SYSTEM\_IMAGE, which corresponds to a right-handed-y-down coordinate frame. As ZED\_Sensor\_Viewer displays the coordinates in IMAGE, this corresponds with the difference in signs that you are experiencing.

---

<div class="post-metadata">

**Author:** ![mattrouss](https://community.stereolabs.com/user_avatar/community.stereolabs.com/mattrouss/32/2452_2.png) [@mattrouss](https://community.stereolabs.com/u/mattrouss)\
**Post date:** [March 20, 2024, 3:51pm UTC](https://community.stereolabs.com/t/rotation-angles-for-the-point-cloud/4768/7 "2024-03-20T15:51:00Z")

</div>

I apologize the documentation is a bit confusing about the conventions.

> Euler angles created from the [sl::Pose](https://www.stereolabs.com/docs/api/classsl_1_1Pose.html) values as a [sl::float3](https://www.stereolabs.com/docs/api/namespacesl.html#aa21e242f2d030e0f1878f8a5854c35e2) representing the rotations around the X, Y and Z axes using YZX convention.

By calling getEulerAngles(), you retrieve the values in a float3 in the order float3(X, Y, Z), in the COORDINATE\_SYSTEM defined in the InitParameters.

The “YZX convention” is the convention that describes the order in which the rotations are applied, i.e. we first rotate around the Y axis, then Z, then X.

I hope this helps your understanding of the method.
