# Does consequtive Set?Axis() commands overrides the previous one

**URL:** <https://root-forum.cern.ch/t/does-consequtive-set-axis-commands-overrides-the-previous-one/56602>\
**Category:** Newbie\
**Created:** [October 4, 2023, 1:44pm UTC](https://root-forum.cern.ch/t/does-consequtive-set-axis-commands-overrides-the-previous-one/56602 "2023-10-04T13:44:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Siddharth\_Parashari](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/siddharth_parashari/32/25501_2.png) [@Siddharth\_Parashari](https://root-forum.cern.ch/u/Siddharth_Parashari)\
**Post date:** [October 4, 2023, 1:44pm UTC](https://root-forum.cern.ch/t/does-consequtive-set-axis-commands-overrides-the-previous-one/56602/1 "2023-10-04T13:44:45Z")

</div>

Hi,  
I am trying to use TRotation class member functions to rotate and transform one coordinate system into another. So I need my Z axis to be in parallel to the direction of gamma propagation and Y axis to be perpendicular to the ZX plane. I have initial gamma propagation and a cross product to find Y. I am trying the following,

```auto
TVector3 initial_gamma1_dir, intitial_gamma2_dir;
TRotation R1,R2;

initial_gamma1_dir.SetXYZ(0,0,50);
initial_gamma2_dir.SetXYZ(0,0,-50);

A_x_B = initial_gamma1_dir.Cross(initial_gamma2_dir);

R1.SetYAxis(A_x_B); 
R1.SetZAxis(initial_gamma1_dir);
 
R2.SetYAxis(A_x_B); 
R2.SetZAxis(initial_gamma2_dir);

```

… something like this.

Later I use R1 and R2 to transform the coordinate system.

My question is, does consecutive rotation using Set?Axis() overrides the previous one.

_ROOT Version:_ 6.28/06  
_Platform:_ Ubuntu 22.04  
_Compiler:_ C++17

* * *

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [October 4, 2023, 1:52pm UTC](https://root-forum.cern.ch/t/does-consequtive-set-axis-commands-overrides-the-previous-one/56602/2 "2023-10-04T13:52:37Z")

</div>

> [@Siddharth\_Parashari](#):
>
> does consecutive rotation using Set?Axis() overrides the previous one

Looking at the code (e.g. [TRotation::SetYAxis](https://root.cern.ch/doc/master/TRotation_8cxx_source.html#l00720)), I would say yes, but I might be wrong… Did you try?

---

<div class="post-metadata">

**Author:** ![Siddharth\_Parashari](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/siddharth_parashari/32/25501_2.png) [@Siddharth\_Parashari](https://root-forum.cern.ch/u/Siddharth_Parashari)\
**Post date:** [October 4, 2023, 2:17pm UTC](https://root-forum.cern.ch/t/does-consequtive-set-axis-commands-overrides-the-previous-one/56602/3 "2023-10-04T14:17:41Z")

</div>

Hello Bellenot,

Yeah, I tried.  
The motive is to make the ‘Z’ axis in the direction of gamma and the ‘Y’ axis in the direction of (A\_X\_B).  
I think, rather trying to these steps separately, I should use

```auto
R1.SetYAxis(A_x_B,initial_gamma1_dir);

```

This will make the direction of Y axis perpendicular to the gamma propagation and the gamma propagation direction will also be in YZ plane. Is it correct?

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [October 4, 2023, 2:30pm UTC](https://root-forum.cern.ch/t/does-consequtive-set-axis-commands-overrides-the-previous-one/56602/4 "2023-10-04T14:30:09Z")

</div>

Well, sorry but I don’t know. I think it will be easier for you to try out and see if it gives what you expect…
