# Turn a quaternion

Hey there I have a quaternion q and I would like to turn that.

Therefore I tried:

```
tf::Quaternion q( four_result_pose.orientation.x, four_result_pose.orientation.y, four_result_pose.orientation.z, four_result_pose.orientation.w);
tf::Matrix3x3 m = tf::getRotation(q);
tf::Matrix3x3 x_90_deg_turn;
tf::Matrix3x3 result_matrix = m *x_90_deg_turn.setRPY(1,0,0); //(TODO - DOES NOT WORK)
// TODO how to give back the quaternion result?
```

Is there any Matrix3x3 function to convert a Matrix3x3 to a quaternion???

**Solution**

```
tf::Quaternion q( four_result_pose.orientation.x, four_result_pose.orientation.y, four_result_pose.orientation.z, four_result_pose.orientation.w);
tf::Matrix3x3 m(q);
tf::Matrix3x3 x_90_deg_turn;
x_90_deg_turn.setEulerYPR(+1.57079632679, 0, 0);
tf::Matrix3x3 result_matrix = m*x_90_deg_turn;
double res_yaw;
double res_pitch;
double res_roll;
result_matrix.getRPY(res_yaw, res_pitch, res_roll);
q.setRPY(res_yaw, res_pitch, res_roll);
```

Do not know how to turn it correctly??

How to set setEulerYPR(+1.57079632679, 0, 0); So that the outer coordinate systems are turned into the one in the middle around the x axis by 90 degree. so that the y axis goes up the x axis right and the z axis out of the image.

See this image:

wiki/tf2/Tutorials/Quaternions might help you here.

`.setEulerYPR(+1.57079632679, 0, 0);`

rotates`+pi/2`

around z-axis, not x. See here for the definitionAnd the matrix multiplication should be

`x_90_deg_turn*m`

instead of`m*x_90_deg_turn`