Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
6
Question by tomasherrera · Jun 23, 2011 at 04:44 AM · quaternion

How the Quaternion Works?

Somebody can explain me what its a Quaternion, and how can i use it to rotate my 3d objects? I really frustated about it, and a i need it for a project i actually doing to the college. Thanks..

Comment
Add comment · Show 3
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 flaviusxvii · Jun 23, 2011 at 02:27 PM 2
Share

I've been using them for years, I have a superior knowledge of Linear Algebra / Vector mathematics, and I don't have the slightest clue as to how quaternions are able to do what they do.

avatar image Tasarran · Jun 23, 2011 at 05:23 PM 0
Share

Yeah, Quaternions are a black box for most people (me included).

You create them from functions using rotations and other vars, then you apply that to other rotations, but you don't need to know what's in the box, just that this box will change your rotation 60 degrees to the left, and that box will rotate you to the right, etc...

avatar image Fattie · Oct 15, 2012 at 08:16 PM 0
Share

click to unitygems.com

3 Replies

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

Answer by _Petroz · Jun 23, 2011 at 05:01 AM

A Quaternion represents a rotation. The underlying math is quite complicated but you don't need to understand that to use them with Unity.

Here are the docs for the Quaternion class: http://unity3d.com/support/documentation/ScriptReference/Quaternion.html

The documentation for Ogre explains some of the advantages of Quaternions:

  • Axis/angle representation avoids gimbal lock.

  • Modifying a rotation is easy. Say we have a rotation describing a -45 degree yaw (left turn). By creating a new quaternion describing a 10 degree yaw (right turn) and multiplying the two, we now have a rotation describing a -35 degree turn. You might use this when applying the same rotation to a number of different objects, or even multiple times to the same object (i.e. the player). The rotation factor increases or decreases depending on circumstances.

  • Avoids costly alignment of matrix drift. This drift occurs when performing lots of operations on matrices using finite point precision, which is used in your computer. Rounding of real numbers graudally builds up and inevitably mucks up the matrix. Abnormalities in the rotation will start to appear due to this drift. The matrix must be normalized in order to reset this, however it is a costly operation. Quaternions on the other hand can still suffer from this drift, but it is much cheaper to normalize having only 4 values instead of 9 or more.

  • Interpolation of rotations. When rotating an object, we might want the object to rotate smoothly over time. We'd like to say, "From your current orientation, rotate to face this point. But take about 300 frames to do it, so only move 1/300th of the rotation right now." Interpolation with matrices is possible, but then so is anything, isn't it? Quaternions provide two methods of interpolation: linear(slerp) and cubic(squad). Ogre provides three implementations: slerp, nlerp and squad. Linear interpolation allows one to specify the percentage of interpolation between the two quaternions. Linear means your "velocity" of movement is constant, which may feel jerky if used for a camera or object. Slerp and nlerp are both linear. Slerp is more accurate, but slower. Squad or cubic interpolation allows one to specify four quaternions a,p,q,b. P and Q are used to define a curve of interpolation "velocity" between points A and B. This allows us to slowly increase speed, stay constant, then decrease it during interpolation. See the External Resources section for links that will elaborate on this.

Taken from: http://www.ogre3d.org/tikiwiki/Quaternion+and+Rotation+Primer&structure=Tutorials

Comment
Add comment · Show 1 · 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 Demigiant · Oct 15, 2012 at 07:40 PM 0
Share

Great answer :)

avatar image
3

Answer by Meltdown · Jun 23, 2011 at 05:41 PM

Here is a youtube video of a guy that explains it pretty well :)

http://www.youtube.com/watch?v=WkBno2c06ZU

EDIT : Here's a more thorough one from site I was told of today...

http://unitygems.com/quaternions-rotations-part-1-c/

Comment
Add comment · Show 2 · 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 code-blep · Oct 15, 2012 at 07:10 PM 0
Share

That is a great explanation. I still don't fully get them but definitely understand them better. Good shout Greg!

avatar image Meltdown · Oct 15, 2012 at 07:27 PM 0
Share

I edited my answer to show another link.

avatar image
2

Answer by deCalle · Mar 25, 2016 at 05:55 PM

A quaternion is a vector with a rotation angle attached...

So think about a Quaternion to be a Vector3 that points anywhere in the XYZ Dimension. Its direction actually is a rotation itself (Imagine every point on the unit circle can be displayed as a simple Vector2, so the same goes for 3D). Additionaly the Vector has another Angle parameter that lets it rotate around its personal Z axis (or roll it like a cigarette^^).

Actually I don't know yet how to directly manipulate the parameters, but don't be afraid to play around with it, Quaternions actually aren't some ungraspable mathematical divinity you mustn't touch as long as you don't have a PhD.

There are many people out there that tell you shit to block you on your way, like in primary school when everybody told you math is soo hard and you believed it and made school math an unbeatable giant.

MYTH busted, so go out there and program the shit out of your game ;-) (Grow, Grow my little Sprouts for only personal growth is infinite^^)

Comment
Add comment · Show 1 · 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 Bunny83 · Mar 25, 2016 at 11:36 PM 0
Share

Quaternions really aren't that difficult ^^. See this Numberphile video

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

10 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

Related Questions

Rotate Turret back to match base 1 Answer

Doing 2D only rotation using FromToRotation + RotateTowards 0 Answers

[SOLVED]How to change Quaternion by 180 degrees? 5 Answers

Rotation based player Rotation and Camera Rotation 0 Answers

Efficiency of transform.forward, up, and right 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