- Home /

# How to flip a Quaternion to face the opposite direction, without knowing the axis

Hello there. My question is probably more complicated than it seems (or perhaps it's a lot more simple - I don't know...).

I've checked various questions, documentation and posts here, but I remain unclear about this...

I'd like to know if Quaternion.Inverse 'flips' the rotation around 180 degrees, or does it return a rotation that would, when multiplied (added, I guess) to the original, produce an identity Quaternion? That is, one without any rotation.

To me, it seems like the 'inverse' of a rotation is different to a rotation facing in the opposite direction. The opposite direction, when multiplied (added) to the original will not send the rotation back to '0', right? It will make it U-turn.

So how do I 'flip' a Quaternion 180 degrees, without necessarily knowing the axis? Cheers.

**Answer** by EvilTak
·
Jan 11, 2016 at 10:39 AM

Try

```
Quaternion rot180degrees = Quaternion.Euler(-originalRot.eulerAngles)
```

You are correct, Inverse returns the multiplicative inverse of the Quaternion.

```
print(Quaternion.Inverse(quat) * quat == Quaternion.identity); // Prints true
print(Quaternion.Euler(-quat.eulerAngles) * quat == Quaternion.identity); // Prints false
```

Why `Quaternion.Inverse()`

don't yield same result? (I've checked - it really don't)

Replying for those that are Googling. It is because Inverse() of a Quaternion is sort of an "undo". So the Inverse line can be read as something like -3 + 3 = 0. (3 is a purely fictional number here). Quaternion can be seen as "rotation commands"

Sorry but this actually makes no sense, just like the question doesn't make much sense. This does not flip the rotation by 180° around any axis. If the eulerangles are 0,0,0, nothing will happen. The same is actually true for a rotation like 0,180,0 (so we actually face the opposite direction). If you negate this eulerangles representation you get 0,-180,0 which is the same rotation as 0,180,0

Negating does quite different things depending on what the actual rotation was. So 0,10,0 turns into 0,-10,0 which can be seen as a "flip" through the y-z-plane. Though a rotation like 10,0,0 would become -10,0,0 which would be a flip through the x-z-plane. Though a rotation like 10,10,0 (10 degrees to the right and 10 degrees down) would become -10,-10,0 (10 degrees to the left and 10 degrees up). So the flip would go through a diagonal plane. This all has nothing to do with "turning 180°"

Flipping 180° makes no sense without specifying an axis. If you flip a car 180° around it's x-axis the car will be upside down, the front will be back but left is still left and right is still right. Though when flipping 180° around the z-axis, forward will still be forward but the car is again upside down and left is now right and right is left. Finally flipping the car around the y-axis would simply turn it around. So front is back, left is right, but up is still up.

Quaternion.Inverse returns the inverse rotation from the given rotation. Rotations are always relative ("absolute" rotations are just relative rotations applied to the default orientation). Unlike euler angles which are 3 consecutive rotations, Quaterions represent a rotation as a single operation. The rotation order in euler angles rotations does matter. Imagine you rotate your object from (0,0,0) by (90,90,0). This will rotate your object 90° around the local y-axis followed by 90° around the now local x-axis. So the first rotation makes you look to the right the second makes you look up. If you would now apply a relative rotation of (-90, -90, 0) it won't undo the current rotation. Because from the current orientation when you rotate -90° around the local y axis you will look along the world forward but you are tilted around z by 90°. If you then do the -90 on the local x you will look to the world right direction and be tilted around Z by 90°.

### Your answer

### Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.