Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by moosefetcher · Jan 11, 2016 at 10:26 AM · rotationquaternioninverse

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
4
Best Answer

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





Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SaSha_K · Feb 01, 2017 at 12:47 PM 0
Share

Why Quaternion.Inverse() don't yield same result? (I've checked - it really don't)

avatar image Jordii SaSha_K · Apr 20, 2018 at 02:09 PM 0
Share

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"

avatar image Bunny83 · Apr 20, 2018 at 03:01 PM 5
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

38 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What is the rotation equivalent of InverseTransformPoint? 3 Answers

Relative rotation while moving on parent. 1 Answer

Rotate multiple objects around a object, maintaining their own trajectory(not rotating their local forward vector) 1 Answer

Smooth rotation about global axis instead of local axis. 1 Answer

Rotation - Simple Question 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges