# Quaternion.Euler rotations don't add up

My team has been trying for a day to get rotations to work on a vector. We read Quaternions can easily be multiplied with a vector to get the desired rotated vector. However, there seems to be something we don’t quite understand. For example we’d expect the following code to rotate vector x to its original orientation, since each rotation axis adds up to a rotation of 360 degrees.

``````Vector3 x_a = new Vector(13,4,5); // Just an example
Vector3 x_b = Quaternion.Euler(new Vector(180,300,350)) * x_a;
Vector3 x_c = Quaternion.Euler(new Vector(180, 60, 10)) * x_b;
``````

However, x_c != x_a.

Can someone explain the intended use of Quaternion.Euler to us? (How) could this example be changed to make x_c equal x_a?

The rotations in Q-Euler are around the world axes I believe (in the order z, x, y). Work through with this on paper and you’ll probably find it’s correct. On paper treat Vector x as a point in space.

Place a cube at the point in space determined by your x vector. Apply the two rotations you created to the cube via script and you will see the same results.

Place the following onto a script and place it on a cube with position 13,4,5. It simply performs each rotation one axis at a time so you can see whats going on a bit better.

``````#pragma strict

var timer : float = 0.0;
var stage1 : boolean = true;
var stage2 : boolean = true;
var stage3 : boolean = true;
var stage4 : boolean = true;
var stage5 : boolean = true;
var stage6 : boolean = true;

function Update()
{
timer += Time.deltaTime;

if (timer >= 3.0 && stage1)
{
transform.position = Quaternion.Euler(0,0,350) * transform.position;
stage1 = false;
}
if (timer >= 6.0 && stage2)
{
transform.position = Quaternion.Euler(180,0,0) * transform.position;
stage2 = false;
}
if (timer >= 9.0 && stage3)
{
transform.position = Quaternion.Euler(0,300,0) * transform.position;
stage3 = false;
}
if (timer >= 12.0 && stage4)
{
transform.position = Quaternion.Euler(0,0,10) * transform.position;
stage4 = false;
}
if (timer >= 15.0 && stage5)
{
transform.position = Quaternion.Euler(180,0,0) * transform.position;
stage5 = false;
}
if (timer >= 18.0 && stage6)
{
transform.position = Quaternion.Euler(0,60,0) * transform.position;
stage6 = false;
}
}
``````