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
1
Question by sol · Feb 23, 2011 at 02:41 PM · rotationquaternionslerp

Extrapolating a new rotation from two existing rotations.

I have two rotations of an object that are a given time apart. From these I would like to extrapolate the rotation in the next frame assuming the object has a constant rotational velocity. Slerp() will interpolate between two rotations but my understanding is that the "t" argument must be between 0 and 1. I'm looking for the equivalent of Slerp() that accepts "t" values greater than one.

Perhaps quaternion operations can be used to find the difference between the first and second rotations and then this difference can be applied to the second rotation yielding the next rotation in the sequence. My understanding of quaternions is still rather slim. I appreciate any suggestions that you might have.

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
0

Answer by cregox · Feb 23, 2011 at 06:34 PM

Assuming the rotational velocity is constant, like you said, we just need the difference between the first two to add up and get the third rotation. Don't need to understand quaternions rotations for doing that. Just do all math in Euler angles and rotate using Quaternion.FromToRotation:

function extrapolateLinearRotation (var dir1, var dir2) {
    var dir3 = dir1 - dir2;
    dir3 = dir2 + dir3;
    return Quaternion.FromToRotation(dir2, dir3);
}

edit: This will only account for 1 plane rotation, and will not get the vector spin as Jessy pointed on the comments. My actual point here was that it's important to do the actual rotation with quaternions to avoid a Gimbal Lock.

Picture this on a dice, if you will. This will be confusing.

Number 1 on the top, number 2 on the front, number 3 on the right. Now rotate the dice upwards so number 1 gets on the back, 2 on the top and 6 on the front. 3 stays on the right. This code will notice that change and next step number 1 is on the bottom. But it won't account for any changes on number 3. If from step 1 to step 2 we have moved number 3 to the left, on step 3 number 3 should be moved back to the right to continue its spin. That just doesn't happen with FromToRotation.

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 Jessy · Feb 23, 2011 at 08:08 PM 1
Share

Unfortunately, this doesn't account for spin around the vector you're tracking. It may work if that's not an issue, though. I use FromToRotation for 2D rotations, because I don't know any better yet. :-D

avatar image cregox · Feb 24, 2011 at 03:43 PM 0
Share

@Jessy yes, that's true... This will rotate in just one 2D plane. I think I wrongly assumed "constant velocity" as being 2D. It's hard to get my head around this subject sometimes! :)

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

No one has followed this question yet.

Related Questions

Rotation of an object with quaternion 1 Answer

Choppy rotation of character around y-axis 1 Answer

i want to get my to cube to rotate 90 degrees on the x-axis as it jumps 0 Answers

Stage selection problem 1 Answer

Changing rotation of Quaternion 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