# Convert Rotation from world to local

**URL:** <https://forum.babylonjs.com/t/convert-rotation-from-world-to-local/23159>\
**Category:** Questions\
**Created:** [August 18, 2021, 6:47am UTC](https://forum.babylonjs.com/t/convert-rotation-from-world-to-local/23159 "2021-08-18T06:47:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ynnek](https://avatars.discourse-cdn.com/v4/letter/y/c68b51/32.png) [@ynnek](https://forum.babylonjs.com/u/ynnek)\
**Post date:** [August 18, 2021, 6:47am UTC](https://forum.babylonjs.com/t/convert-rotation-from-world-to-local/23159/1 "2021-08-18T06:47:08Z")

</div>

Hi all!

I’m trying to convert rotation from world to local.

In details, there are 3 meshes, parentBox, childBox and anotherBox.  
And parentBox is the parent of childBox.

What I want to do is,

1. get center world rotation using parentBox’s world rotation and anotherBox’s world rotation
2. convert center rotation from world to local (local to parentBox because I want to apply it to the childBox)
3. apply the converted local rotation to childBox

I tried the same logic with positions, and it worked well.  
But with rotations, it didn’t work like I wanted…

In the playground below, the position of the childBox will be changed after 1000 ms in the way I want.  
And after 2000 ms, the rotation will be changed in the way I don’t intend…

I want the childBox have green front and red up…

[https://playground.babylonjs.com/#MAC3I2#10](https://playground.babylonjs.com/#MAC3I2#10)

Can somebody help me to solve this problem??  
Thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 18, 2021, 10:13am UTC](https://forum.babylonjs.com/t/convert-rotation-from-world-to-local/23159/3 "2021-08-18T10:13:07Z")

</div>

You can’t transform a vector of euler angles by a matrix. In your case, to “undo” the rotation of the parent you simply need to negate its euler angles (the `rotation` property) and then add the rotation you want for your child cube:

[https://playground.babylonjs.com/#MAC3I2#15](https://playground.babylonjs.com/#MAC3I2#15)

---

<div class="post-metadata">

**Author:** ![ynnek](https://avatars.discourse-cdn.com/v4/letter/y/c68b51/32.png) [@ynnek](https://forum.babylonjs.com/u/ynnek)\
**Post date:** [August 18, 2021, 10:35am UTC](https://forum.babylonjs.com/t/convert-rotation-from-world-to-local/23159/4 "2021-08-18T10:35:50Z")

</div>

Thank you @Evgeni_Popov!

Then, in the case of rotationQuaternion, do I have to convert quaternion to euler value and follow the same way above as well?

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 18, 2021, 11:12am UTC](https://forum.babylonjs.com/t/convert-rotation-from-world-to-local/23159/5 "2021-08-18T11:12:51Z")

</div>

Yes, or you can do as for the translation case (where you multiply the final translation by the inverse transformation of the parent), multiplying the final quaternion you want to apply by the inverse quaternion of the parent.

---

<div class="post-metadata">

**Author:** ![ynnek](https://avatars.discourse-cdn.com/v4/letter/y/c68b51/32.png) [@ynnek](https://forum.babylonjs.com/u/ynnek)\
**Post date:** [August 18, 2021, 11:41am UTC](https://forum.babylonjs.com/t/convert-rotation-from-world-to-local/23159/6 "2021-08-18T11:41:05Z")

</div>

Thank you so mush for your help, @Evgeni_Popov !
