Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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
4
Question by sol · Feb 23, 2011 at 04:26 PM · rotationquaternionvelocityangular

Rotation quaternion to angular velocity

Given an object's rotation over a given time period I would like to calculate its angular velocity. Here is what I think I need to do:

1) Scale the quaternion that represents the rotation of the object by the period of time over which the rotation occurred.

2) Convert the quaternion to a Vector3 angular velocity.

The documentation doesn't specify how angular velocity is represented other than to show that it is a Vector3. I suspect that the vector's direction represents the axis of rotation of the object and its magnitude represents the rate of rotation.

On the other hand the Vector3 returned by quaternion.eulerAngles contain rotations in degrees not a vector representing an axis of rotation. I believe that there is a way to get from the quaternion to the angular velocity vector but I don't know the right approach.

Thank for any help you can provide.

Comment
Add comment · Show 1
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 cregox · Feb 23, 2011 at 05:09 PM 0
Share

related: http://answers.unity3d.com/questions/29186/velocity-and-angular-velocity-of-an-object/29190#29190

2 Replies

· Add your reply
  • Sort: 
avatar image
9

Answer by Nimred · Jan 31, 2015 at 03:11 PM

This is an old question but I couldn't find a good answer anywhere in Unity Answers, I thought I'd share what I figured out:

  • The angular velocity is indeed the rotation axis, normalized, multiplied by the rotation speed in radians.

  • Quaternion.ToAngleAxis(out angle, out axis) give a rotation's axis, and the angle IN DEGREES.

So in order to get an angular velocity from a Quaternion, you can do the following:

 float angleInDegrees;
 Vector3 rotationAxis;
 myQuaternion.ToAngleAxis(out angleInDegrees, out rotationAxis);
 
 Vector3 angularDisplacement = rotationAxis * angleInDegrees * Mathf.Deg2Rad;    
 Vector3 angularSpeed = angularDisplacement / Time.deltaTime;




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 SergeantBiscuits · Mar 06, 2015 at 10:24 PM 2
Share

This is awesome--thank you for posting this. Exactly what I needed.

For anyone else hunting down this information, if you need the relative angular velocity, use:

 Vector3 angularSpeed = transform.rotation * (angularDisplacement / Time.deltaTime);
avatar image julkiewicz SergeantBiscuits · Nov 24, 2017 at 05:01 AM 0
Share

Wow, can I send you a $100 bill? I just spent hours looking for that answer.

This comment doesn't get enough credit. So basically if you have a quaternion rotation that you want your rigidbody to follow - you assign to rigidbody.angularVelocity what @$$anonymous$$antBiscuits wrote. Not the original formula.

avatar image
1

Answer by hellcats · Feb 25, 2011 at 03:19 AM

The problem is that scaling the quaternion won't work because it will no longer be a rotation (it has to be unit length to represent a rotation). The Slerp function does something similar to what you want and is a clue. Here is Slerp:

Slerp(q0, q1, t) = q(t) = (q1 q0*)^t q0
(q0* is Conj[q0], which is the inverse for unit length quaternions)

This interpolates between two rotations q0 and q1 with t varying from [0, 1]. So if you think of t as being time, then the time derivative dq/dt is:

Log[q1 q0*] (q1 q0*)^t q0

also,

dq/dt = 1/2 w(t) q(t)

Note the equivalent form, the Log[q1 q0*] part of dq/dt matches with 1/2 w(t), so the angular velocity is:

2 Log[q1 q0*]

For unit length quaternions this evaluates to

2 v / ||v|| ArcCos(s)

where quaterion q is (s, vx, vy, vz) (i.e. s is the scalar part and v the vector part)

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 hellcats · Feb 25, 2011 at 03:48 AM 1
Share

One additional detail: the above derivation made the assumption that t (which varies from 0 to 1) is time, but that assumption is only valid if you are using two rotations 1 sec. apart. If your rotations are 1/60 second apart, then you will have to multiply the answer by 60.

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

2 People are following this question.

avatar image avatar image

Related Questions

Instantly rotating and changing an object's velocity relative to another (probably quaternion mistake!) 1 Answer

Torque towards Quaternion. 0 Answers

How to make rigidbody rotation more unstoppable 0 Answers

Rotation based on Velocity returning 0,0,0 rotation 1 Answer

Camera.WorldToScreenPoint Equivalent 1 Answer


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