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
2
Question by Kiloblargh · Jun 27, 2012 at 04:43 PM · rotationtransformquaternionmathinverse

What is the rotation equivalent of InverseTransformPoint?

from the docs: "Transform.InverseTransformPoint transforms position from world space to local space."

[some gnarly equation that's a mystery to me?] transforms rotation from world space to local space.

There is no such thing as Quaternion.InverseTransformRotation, but if there were, that would be exactly what I'm looking for. It's also what happens automatically to the localRotation when you parent an arbitrarily rotated object to some other arbitrarily rotated object, but there has to be a better way than actually parenting and unparenting objects every frame...?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
10

Answer by Steven-1 · Aug 11, 2015 at 09:16 PM

What Owen said is almost correct. The correct formula is:

 Quaternion LocalRotation = Quaternion.Inverse(Target.transform.rotation) * WorldRotation;
 //this will transform WorldRotation to Target's local space
Comment
Add comment · Show 4 · 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 Ossorum · May 29, 2017 at 02:59 PM 0
Share

How would that work the other way, local to world rotation?

avatar image Taylor-Libonati Ossorum · Jun 20, 2017 at 08:07 PM 2
Share

I think this?

  Quaternion WorldRotation = Target.Transform.rotation * rotation;
 //Transforms rotation from Targets local space to world space

avatar image Meceka Ossorum · Mar 27, 2020 at 03:50 PM 0
Share

Quaternion worldRotation= transform.parent.rotation * localRotation;

I could get world rotation from local like this;

avatar image gregp203 · Sep 18, 2018 at 07:39 PM 0
Share

I ran into this problem with ParticleCollisionEvent.normal. I wanted to instantiate an object and physicaly connect it to an object that collided with a particles from a particle system. ParticleCollisionEvent uses world position and rotation . If the object with the collider collided with the particles from a different angle the object attached to it would be at the wrong angle. after spending all day trying, I came up with thisQuaternion.LookRotation(particleCollisionEvent.normal) * Quaternion.Inverse(transform.rotation.normalized) . Then I wondered if there was a world-to-local method for rotation and google brought me to this thread found the same answer.

avatar image
2

Answer by Owen-Reynolds · Jun 27, 2012 at 05:02 PM

Only partially tested: the local rotation from object P seems like it's your world rotation "minus" P's rotation. The opposite of a rotation is the Inverse, so:

 Quaternion localRotFromP = transform.rotation * P.rotation.Inverse();

As a check, when you use local to get world, you multiply by the "parent" rotation. If we do that to our computed local, we get trans.rot * P.rot.Inv * P.rot. The last two terms cancel (Quat mult isn't commutative, but is still associative) and you get your real rotation back.

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 Steven-1 · Aug 11, 2015 at 08:36 PM 0
Share

shouldn't it be the other way? Quaternion localRotFromP = Quaternion.Inverse(transform.rotation) * P.rotation;

avatar image
1

Answer by Chuck 1 · Jun 27, 2012 at 06:24 PM

What about Quaternion.Inverse?

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

12 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

Related Questions

Quaternions local/world 1 Answer

Random.rotationUniform clarification 4 Answers

How to smoothly rotate to certain directions using input axis 1 Answer

Rotation Jumping values (0 to 180) 1 Answer

Opposite angle rotation 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