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
1
Question by huubh · Aug 21, 2017 at 08:48 PM · transformpositionquaternioncoordinatescoordinate

Transform vector to other coordinate frame using quaternions

In common math, one can describe a vector in another coordinate frame by pre an post multiplying the vector with a quaternion as described on page 25/26 of this document:

https://www.ethz.ch/content/dam/ethz/special-interest/mavt/robotics-n-intelligent-systems/rsl-dam/documents/RobotDynamics2016/RD2016script.pdf

In short:


  1. We have a vector in the world coordinate frame from the world to an object v_w2o_w (vector from world to object in world coordinates).

  2. We have a rotation quaternion from the world to the player coordinate frame q_w2p (rotation from world to player).

  3. We are interested in the direction the object is in according to the world coordinates, but in the player coordinate frame. Therefore, we are interested in the vector v_w2o_p.

  4. According to literature, you can obtain this vector by doing the following:

    v_w2o_p = q_w2p X v_w2o_w X q_w2p


The problem is that Unity does not allow post-multiplication of quaternions. Without using parent objects, how do we obtain the vector v_w2o_p ?

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
Best Answer

Answer by Bunny83 · Aug 21, 2017 at 11:38 PM

Uhm, your question is very confusing. First of all a Quaternion does not represent a coordinate system but just a rotation or rotational space. So you only deal with directions. Directions don't have a reference point.

Next page 26 mainly deals with transformation matrices which do represent a coordinate system as they combine a rotation and a translation.

If i understood your problem right you have an object "O" somewhere in worldspace. You also have your player object "P". You want a local space direction vector inside the player space from P towards O.

First you would have to create the world space direction vector from P to O. So all you have to do is subtracting the two positions

 V = O - P

V will be the worldspace direction from P to O. To convert this world space direction into a local space direction you either need the inverse transformation matrix (worldToLocal) or the inverse of the Quaternion of your player. You can calculate the inverse of a quaternion by using Quaternion.Inverse. All you have to do now is multiplying the resulting quaternion with your vector V.

You may be confused by Unity's Quaternion struct. When you multiply a quaterion with a Vector3 you actually rotate the vector. So it does both multiplications at once. If "q" is your rotation quaterion and "q*" the conjugate, what unity basically does when you multiply a quaternion q with a vector v is this:

(q) x (v) x (q*). Note that "x" is the complex quaternion product.

As you might know q and q* actually look like this:

 q = w + x*i + y*j + z*k
 q* = w - x*i - y*j - z*k



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 huubh · Aug 23, 2017 at 05:39 PM 0
Share

(q) x (v) x (q*). Note that "x" is the complex quaternion product.

Answers my question. Thank you.

Please note that:

v_w2o_w is the DIRECTION from world to the object in the world coordinate frame, as stated in the question.

q_w2p is the ROTATION from the world coordinate frame to the player coordinate frame, as stated in the question.

q_p2w is the ROTATION from the player to the world coordinate frame (i.e., the conjugate of q_w2p )

Hope this makes it easier for the next person to understand both question and answer!

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

89 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Using custom Transform/GameObject classes? 0 Answers

Remember the start coordinates? 2 Answers

mousePosition.x value type. (Equations involving coordinates) 1 Answer

split vector3 coordinates in to x,y,z 1 Answer

What does a Vector3 state? 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