- Home /

# Quaternions rotating the wrong way

Hello,

I'm making a physics simulation that uses quaternions to calculate the rotation of the objects involved. I've written the following method for constructing a quaternion:

```
static Quaternion quatCons(Vector3 axis, float angle) {
axis = axis.normalized;
float s = Mathf.Sin(angle / 2f);
Quaternion result = new Quaternion(s * axis.x, s * axis.y, s * axis.z, Mathf.Cos(angle / 2f));
return result;
}
```

Where `axis`

is the axis around which the rotation takes place, and `angle`

the angle/second at which the rotation happens (in radians).

When trying to simulate the rotation of earth, I use the following code:

```
static Vector3 earthAx = new Vector3(0, 1, 0);
static Quaternion earthRot = quatCons(earthAx, Mathf.PI/43200f*Time.deltaTime);
earthTrans.transform.rotation = earthRot * earthTrans.transform.rotation;
```

According to the rules of quaternion multiplication, this should result in the sphere rotating eastward right? Clockwise rotation when looking in the same direction the axis vector is pointing. The sphere rotates westward though (or anticlockwise), and I have no idea why. Does it have something to do with the way unity multiplies by quaternions? It doesn't really make sense to me.

### People who like this

**Answer** by Bunny83
·
Jan 04, 2018 at 12:34 AM

Uhm, the usual rotation direction is counter clockwise. What makes you think the rotation should be clockwise? Keep in mind that Unity uses a left handed system, not a right handed system.

"The rotation is clockwise if our line of sight points in the same direction as u→" From https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation But if unity rotates counter clockwise I guess I'll just have to keep that in mind, thanks!

The mathematical definition of most concepts uses a right handed system. In a left-handed system most concepts are inverted when compared to a right handed system. This even applies to the vector crossproduct. While you usually use the right-hand-rule, in a left handed system you have to use the left hand rule. C = Cross(A, B) --> A == thumb, B == index finger, C == middle finger.

ps: Unity already has a method to convert and angle and axis into a quaternion: Quaternion.AngleAxis. So there's no need to manually setup the quaternion. Note that AngleAxis takes an angle in degree, not in radians.

**Answer** by OneCept-Games
·
Jan 03, 2018 at 09:09 PM

Rotating an object by the Quaternion directly is complex math. Why not use the Eular method of the Quaternion class and use Vector3 objects instead?

### Your answer

### Update about the future of Unity Answers

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta later in June. **Please note, we are aiming to set Unity Answers to read-only mode on the 31st of May in order to prepare for the final data migration.**

For more information, please read our full announcement.

### Follow this Question

### Related Questions

How to get Quaternion from Transition Matrix 0 Answers

Prevent child rotation but still control it yourself 1 Answer

How to use quaternions to apply an offset to a rotation to calibrate a controller 1 Answer

Get real compass direction 1 Answer

How do i make my Mouselook behave when changing the z rotation? 0 Answers