Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 julienb · Dec 03, 2011 at 08:45 AM · rotationquaternionrotations

Where can I learn about quaternions and how to manage rotations in Unity

I would like to learn how to use quaternions with sample projects and/or visual explanations for better understanding. Any urls, books or videos on rotations ???

I did not get any answers on that question( http://answers.unity3d.com/questions/191343/align-to-floor-in-local-x.html ), and I would like to solve that myself and understand 100% of the code I use anyway...

Comment
Add comment · Show 2
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 syclamoth · Dec 03, 2011 at 08:49 AM 0
Share

How about Google? It's simple and easy to use.

avatar image julienb ♦♦ · Dec 03, 2011 at 01:02 PM 1
Share

I find lots of stuff on google, but nothing very precise and complete. I do find LOTS of people trying to understand it and/or trying explaining it... But no real serious reference...

2 Replies

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

Answer by aldonaletto · Dec 03, 2011 at 05:05 PM

A quaternion is a math representation of a single rotation around an axis - not only the familiar x, y and z axes, but an axis oriented in any direction. Any 3 axes rotation can be converted to a single rotation of some angle around a well calculated axis, what avoids gimbal lock and eases interpolation, thus the Unity team decided to use this approach.

There are two functions, Quaternion.ToAngleAxis and Quaternion.AngleAxis, that convert quaternions to and from the angle/axis representation. Quaternion.ToAngleAxis(out angle, out axis) returns a float in angle that is the rotation angle in degrees, and in axis a vector3 that indicates the direction of the axis.
The relationship between this angle-axis rotation and a quaternion is the following:

1- The w component is the cos(angle/2);
2- The x, y and z components are the axis vector multiplied by sin(angle/2);

Unity could have stored this rotation in a Vector4 structure, indicating the axis in x, y and z, and the angle in w, but they decided to use quaternions because there's a lot of math developed by crazy mathematicians in the past (more than a century ago!) that perform all the necessary operations in a more efficient manner.
When you multiply two quaternions - A B, for instance - you actually combine the two rotations: rotate B first, then rotate the result by A - yes, the rotation order is reversed, right to left. You can also rotate a vector by multiplying it by a quaternion - but in the reversed order, as usual with quaternions: Quaternion Vector3 applies the Quaternion rotation to the Vector3. Thus, if you want to rotate the Vector3.forward vector to a 30 degrees up angle, for instance, you can use this:

   Vector3 forwardUp30 = Quaternion.Euler(-30, 0, 0) * Vector3.forward;

NOTE: I used -30 in this case due to the particular orientation of the X rotation - nothing to do with quaternions!

Well, this is a brief explanation about quaternions; you can have more information reading the article Quaternion Powers (not Unity3D related) and a lot of other articles in internet (although most of these were written from a mathematician point of view, what can be lethal to ordinary human beings like us).

Comment
Add comment · 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
0

Answer by Patyrn · Dec 03, 2011 at 09:26 AM

This might help:

http://unity3dtutorial.com/unity-3d-tutorials/dealing-with-directions-movement-in-unity-3/

It would be awesome if someone who really understood quaternions and vectors could do a real visual overview of all the functions and concepts involved, but alas, it appears no one has.

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

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

Rotate to ground normal and steering direction for a Bicycle? 1 Answer

Rotation changing in untouched axis 1 Answer

Calculating Torque but cant add Quaternion 0 Answers

Lerp 180 degrees while holding B and lerp back 180 degrees when let go of B. 2 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