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 BilboStabbins · Jan 27, 2013 at 08:56 PM · quaternionangleaxis

Explanation of Quaternion.ToAngleAxis(), what it does, when to use.

Hi,

Just wondering if anyone can provide a little more information on what this function does and when to use it. Also, what exactly is an 'angle-axis representation of the rotation'?

Thanks

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Bunny83 · Sep 04, 2016 at 09:40 PM

A lot people seem to have problems to understand what a quaternion actually is. I always suggest to first watch this Numberphile video. It should cover the basics in the most understandable way I've ever seen.

A quaternion actually represents a vector \ axis and an angle around that axis but as a 4 dimensional complex number.

ToAngleAxis just extracts the angle as well as the axis that this quaternion represents

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 SebasSBM · Sep 09, 2016 at 01:00 AM 0
Share

I ended up finding that Quaternions were based on complex numbers months ago (I discovered then that complex numbers existed as well). In any case, the link you posted might be useful for a better understanding of how the quaternions work.

avatar image
1

Answer by Anxo · Jan 27, 2013 at 09:29 PM

It just converts your rotation to a different format. For instance if you are not looking for a Quaternion.Euler Vector 3 but your code is calculating some Axsis instead you can use this to get the axis and angle.

What the example in the documentation does is it sets up to variables and then populates them with the angle and axis of the current transform.

Comment
Add comment · Show 5 · 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 BilboStabbins · Jan 27, 2013 at 11:12 PM 0
Share

Oh I see, that makes more sense now :)

So say for example, my transform has rotation (30, 45, 0). The Angle that's extracted is: 53.65 and Axis: (0.5, 0.8, -0.2). How might I go about interpreting these values, or what can I then go on to use to plug them into?

Thanks

avatar image SebasSBM · Sep 04, 2016 at 03:48 PM 0
Share

Good answer, but I still have a critical doubt about it that haven't been properly explained yet (not in this answer, neither in the docs:

The input args are both "out" flagged (I know what this means). The point is: can I input any crosswise axis, and obtain it's relative angle from the angle arg?

Reading the docs I can guess "well, it seems so... doesn't it?". However, the fact that axis is also out flagged is kinda confusing; I mean, what's the point for it at all?

avatar image Bunny83 SebasSBM · Sep 04, 2016 at 09:46 PM 0
Share

I've posted an answer that might clear up some confusion. Out parameters don't pass in any values. Out parameters can only be used to return values. Those parameters can't be read inside the method.

Out parameters are usually used when a method need to return more than one value.

avatar image SebasSBM SebasSBM · Sep 09, 2016 at 01:12 AM 0
Share

@Bunny83 Due to quaternions mathematics are beyond my current level, I'd rather use them through their methods... Anyway, looking at your comment, quoting: "out parameters don't pass in any values"...

The reason I was interested in this method is because I needed some kind of function that, having a Quaternion and a normalized Vector3 acting as axis, could output the Euler angles relative to the axis. I thought`Quaternion.ToAngleAxis()` might be what I needed, but it seems that it isn't...

Before I thought out args were useful for both input and output, but it seems I was wrong.

avatar image Bunny83 SebasSBM · Sep 09, 2016 at 07:10 AM 0
Share

"out" parameters only "output" a value. Even more: they are required to be set inside the method. What you have in $$anonymous$$d is a "ref" parameter. It's simply passed by reference so the method can read it's content and change it if it wants to.

Eulerangles specify a complete rotational space (no translation). A single axis doesn't specify a space as the orientation of the other axis isn't clear.

Feel free to post a seperate question on your actual problem. $$anonymous$$ake sure you provide more context of what you want to do and what you need those values for.

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

Problem rotating object around particular axis 1 Answer

How can I adapt the AngleAxis speed to match my rigidbody speed? 0 Answers

object is not rotating from right direction 0 Answers

reproducing hingejoint.angle 0 Answers

Quaternion.AngleAxis() is alway using the axis at 0, 0, 0 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