# Order o Rotation Euler3D

**URL:** https://discourse.itk.org/t/order-o-rotation-euler3d/4536
**Category:** Algorithms
**Created:** [October 30, 2021, 1:59pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536 "2021-10-30T13:59:30Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.itk.org/user_avatar/discourse.itk.org/luis_carlos_carneiro/32/1486_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.itk.org/u/Luis_Carlos_Carneiro)
#### Post date: [October 30, 2021, 1:59pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/1 "2021-10-30T13:59:31Z")

</div>

Dear All,

If I do a Registration of Euler3D. The result transform has a Rotation and a Translation.  
Which is the first operation in Rotation. Is in X? Or is in Z?

Thanks,

Luís Gonçalves

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [October 31, 2021, 9:23pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/2 "2021-10-31T21:23:38Z")

</div>

Hello @Luis_Carlos_Carneiro,

The order of rotations in the `Euler3DTransform` depends on user selection, it is either ZYX or ZXY. To see which one, call the [GetComputeZYX](https://itk.org/Doxygen/html/classitk_1_1Euler3DTransform.html#ac8f72c79e6493d03405dc900894ac768) of the `Euler3DTransform`.

---

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.itk.org/user_avatar/discourse.itk.org/luis_carlos_carneiro/32/1486_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.itk.org/u/Luis_Carlos_Carneiro)
#### Post date: [October 31, 2021, 10:46pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/3 "2021-10-31T22:46:00Z")

</div>

I use SimpleITK

sitk.GetComputeZYX(sitk.Euler3DTransform)

gives

AttributeError: module ‘SimpleITK’ has no attribute ‘GetComputeZYX’

* * *

How to use this function in SimpleITK?

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [October 31, 2021, 11:51pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/4 "2021-10-31T23:51:53Z")

</div>

```auto
import SimpleITK as sitk
tx = sitk.Euler3DTransform()
tx.GetComputeZYX()

```

---

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.itk.org/user_avatar/discourse.itk.org/luis_carlos_carneiro/32/1486_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.itk.org/u/Luis_Carlos_Carneiro)
#### Post date: [November 1, 2021, 12:41am UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/5 "2021-11-01T00:41:20Z")

</div>

False. Suppose that is ZYX?

Thanks.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [November 1, 2021, 4:04pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/6 "2021-11-01T16:04:30Z")

</div>

If `GetComputeZYX()` returns false, then the order is ZXY.

---

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.itk.org/user_avatar/discourse.itk.org/luis_carlos_carneiro/32/1486_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.itk.org/u/Luis_Carlos_Carneiro)
#### Post date: [December 1, 2021, 9:44am UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/7 "2021-12-01T09:44:29Z")

</div>

And the data provided by the transform? The data provided for rotation, what the order?  
RotationX RotationY RotationZ XShift Yshift ZShift ?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 1, 2021, 3:40pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/8 "2021-12-01T15:40:36Z")

</div>

From the [docs](https://itk.org/Doxygen/html/classitk_1_1Euler3DTransform.html):

The serialization of the optimizable parameters is an array of 6 elements. The first 3 represents three euler angle of rotation respectively about the X, Y and Z axis. The last 3 parameters defines the translation in each dimension.

The serialization of the fixed parameters is an array of 3 elements defining the center of rotation.

---

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.itk.org/user_avatar/discourse.itk.org/luis_carlos_carneiro/32/1486_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.itk.org/u/Luis_Carlos_Carneiro)
#### Post date: [December 2, 2021, 1:25am UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/9 "2021-12-02T01:25:19Z")

</div>

I am doing the rotations of the transform the following way. Can you please tell if some angles are computed reversed? What I mean if some rotations are reversed.

Z Axe

```auto
    sincosf(dados2[1],&sin1,&cos1);
    new_x = x1f*cos1 + y1f*sin1;
    new_y = -x1f*sin1 + y1f*cos1;
    new_z = z1f;

    x1f=new_x;
    y1f=new_y;
    z1f=new_z;

```

X Axe

```auto
    sincosf(dados2[3],&sin1,&cos1);
    new_z = -y1f*sin1 + z1f*cos1;    
    new_y = y1f*cos1 + z1f*sin1;
    new_x= x1f;

```

Y Axe

```auto
    sincosf(dados2[2],&sin1,&cos1);
    z1f=new_z*cos1 + new_x*sin1;
    y1f=new_y;
    x1f=-new_z*sin1+ new_x*cos1;

```

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 2, 2021, 2:21pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/10 "2021-12-02T14:21:44Z")

</div>

What is `dados2`? You indexing of that array does not seem consistent. Shouldn’t X correspond to 0, Y to 1, and Z to 2? Also your order of variables (zyx) make the formula seem weird.

---

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.itk.org/user_avatar/discourse.itk.org/luis_carlos_carneiro/32/1486_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.itk.org/u/Luis_Carlos_Carneiro)
#### Post date: [December 2, 2021, 2:26pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/11 "2021-12-02T14:26:15Z")

</div>

Yes, I changed the order. 1 is Z , 2 is Y and 3 is X.

The order is ZXY. Is the order of the transform.

Remember:

“If GetComputeZYX() returns false, then the order is ZXY.”

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 2, 2021, 2:44pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/12 "2021-12-02T14:44:38Z")

</div>

Why are you doing it manually? `Euler3DTransform` provides [GetMatrix()](https://itk.org/Doxygen/html/classitk_1_1MatrixOffsetTransformBase.html#a5c5a5fc53f8d79ce2c78d00f8e40209f), and [TransformPoint()](https://itk.org/Doxygen/html/classitk_1_1MatrixOffsetTransformBase.html#a556da80594679cea2e5f25c78c1e75fb) methods. The point of a library is to provide this sort of stuff, so you don’t have to do it yourself.

---

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.itk.org/user_avatar/discourse.itk.org/luis_carlos_carneiro/32/1486_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.itk.org/u/Luis_Carlos_Carneiro)
#### Post date: [December 2, 2021, 2:51pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/13 "2021-12-02T14:51:17Z")

</div>

I am doing all by my self. Only relying in ITK registration. Even the generated images have different size from ITK. Playing with the centers of rotations.

I do the registration with smaller images and apply the transform to the bigger images.

I need help on this. Thanks.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 2, 2021, 4:39pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/15 "2021-12-02T16:39:15Z")

</div>

If you don’t wan to use ITK, why not “steal” the [code from ITK](https://github.com/InsightSoftwareConsortium/ITK/blob/v5.3rc02/Modules/Core/Transform/include/itkEuler3DTransform.hxx#L249-L291)?

---

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.itk.org/user_avatar/discourse.itk.org/luis_carlos_carneiro/32/1486_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.itk.org/u/Luis_Carlos_Carneiro)
#### Post date: [December 2, 2021, 4:43pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/16 "2021-12-02T16:43:58Z")

</div>

I want to improve the features of ITK. Not steal. I will always use ITK registration. I have ethics.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [December 2, 2021, 4:53pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/17 "2021-12-02T16:53:52Z")

</div>

The word steal was under quotation marks. I meant, why not re-use the relevant part of code from ITK, if you don’t want to use ITK transforms module for whatever you are doing. ITK is open source, licensed under Apache 2.0, so using its code in other projects is allowed. Even if those projects are commercial in nature.

---

<div class="post-metadata">

### Author: ![Luis\_Carlos\_Carneiro](https://discourse.itk.org/user_avatar/discourse.itk.org/luis_carlos_carneiro/32/1486_2.png) [@Luis\_Carlos\_Carneiro](https://discourse.itk.org/u/Luis_Carlos_Carneiro)
#### Post date: [December 3, 2021, 3:35pm UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/18 "2021-12-03T15:35:04Z")

</div>

I have no time to explore ITK code. Perhaps consultation, not more.

---

<div class="post-metadata">

### Author: ![spen](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@spen](https://discourse.itk.org/u/spen)
#### Post date: [February 21, 2023, 10:03am UTC](https://discourse.itk.org/t/order-o-rotation-euler3d/4536/19 "2023-02-21T10:03:08Z")

</div>

No need to revive this topic, just for anyone coming here, this comment (and the respective thread) might be helpful: [https://github.com/InsightSoftwareConsortium/itk-torch-transform-bridge/pull/6#issuecomment-1437095078](https://github.com/InsightSoftwareConsortium/itk-torch-transform-bridge/pull/6#issuecomment-1437095078)
