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
0
Question by blitzen · Mar 13, 2012 at 07:59 AM · rotationeuleranglesglobalmeasure

Global Euler Angles

I'm trying to rotate a piece by special conditional increments (ie. 30, then 90, then 150, then 180, then 210, then 270, then 360) on an arbitrary axis in global space. Sounds easy enough, by checking which of these your axis is at and then setting it to the next one. However, in global space, a rotation in one axis will often be translated as changes to the others to keep it showing the way you meant with Unity's Z,X,Y rotation application order. To see an example, try rotating something to 180 degrees in the Y axis, then try doing the same with the X axis to see how it only ever gets 90 degrees away from 0 before changing other axes and coming back down.

There doesn't seem to be a difference between Transform.localEulerAngles and Transform.eulerAngles, both of which return the local ones. Thus, given all the possibilities for how a given global rotation can be represented in the local axis coordinates, is there a way to measure its "global rotation" of only one axis sanely?

Comment
Add comment · Show 2
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 syclamoth · Mar 13, 2012 at 08:07 AM 0
Share

Other than comparing it with objects that have known rotations, probably not. Using euler angles for this isn't a good idea, because the rotation itself isn't actually stored that way- the euler angles are calculated from the Quaternion.

avatar image blitzen · Mar 13, 2012 at 03:21 PM 0
Share

If I take the time to learn how quaternions work, will the global angle be easily readable directly, so I don't have to store them in a separate Vector3 as mentioned below?

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by simubrett · Mar 13, 2012 at 01:43 PM

Well, if you want a rotation about an arbitrary axis, you won't be able to check a single component against a value. Just make another property on the GameObject that stores the object's "current angle" (the 30, 90, 150, ... above) around your arbitrary axis, and have a way to get the "next angle" around that axis given whatever your current angle is. Then just use transform.RotateAround to rotate your object sensibly.

For instance, when you're going from 30 degrees to 90 degrees:

 float CurrentAngle = 30.0f;
 float NextAngle = 90.0f;
 Vector3 axis = new Vector3(whatever);
 
 transform.RotateAround(transform.position, axis, NextAngle - CurrentAngle);


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 blitzen · Mar 13, 2012 at 03:17 PM 0
Share

Thanks. I considered doing that but wanted to make sure I wasn't being wasteful if there was an easier way to calculate a global angle from local Euler angles or directly from the Quaternion. I may end up having to store it statically like that though.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rotation on Android vs. PC 0 Answers

2D animation : problem with rotation interpolation 1 Answer

trying to RotateAround an object around another object using mouse 1 Answer

Trouble applying rotation locally instead of globally -1 Answers

Edited mouselook script rotation clamp not working 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