Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 guru20 · Aug 09, 2015 at 05:11 AM · rotationvector3quaternionangleangles

Set rotation based on 1,1,1 style vector? How to convert vector3 to quaternion?

Okay, I'm up against something of a mathematical/conversion issue and I'm not experienced enough switching between Vector3, Euler, and Quaternions to know the best way to do this:

I have an angle (x, y, z) determined not as Euler angles, but in the 0-1 float format [I'm not sure what the term for it is, but I'm using normal Vector x/y/z where 1.0 = 90 degrees, ie up = (0, 1, 0), ie (0 x, 90 y, 0 z)]

I need to set a new GameObject's rotation based on these Vector3 values... how could I do that? (I am doing this based on x/y cartesian coordinates on a place so I can, of course, use trigonometry to figure out the euler angles, but it will be much faster and cleaner if I can do it non-Euler)

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 cjdev · Aug 09, 2015 at 05:53 AM 0
Share

From the sound of it you have unit vectors, not angles. Are you measuring the angle between them and another vector?

avatar image sparkzbarca · Aug 09, 2015 at 06:10 AM 0
Share

I would imagine he is either misspeaking and meant 0-360 or he's using some kind of shortest angle assumption where he only works within one quadrant so 127 is actually represent as 127 - 90 = 37 degrees which is roughly .34 or so in a particular quadrant.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sparkzbarca · Aug 09, 2015 at 06:07 AM

you can't safely convert vector3 to quat and back.

the best you can do is quanterion.euler(...);

The issue is quanternions have 4 elements and vectors have 3 and there simply is no way to go from quan to vector without losing some data and no way to from vector 3 to quan without picking one of multiple valid answers.

http://blog.preoccupiedgames.com/quaternions-not-satan/

Notice it says there can be multiple euler representations for one rotation.

that 0, 180, 0 is the same as 180, 0 , 180.

YOu might say well just pick one, except while those two rotations are the same, adding something to them doesn't both produce the same rotation.

So that's the problem, quats have exactly one answer for any rotation and adding them always gets the same answer.

but 0,180,0 + 90,0,0 to 90,180,0 isn't facing the same direction as 180,0,180 + 90,0,0 to 270,0,180

even though 0, 180,0 is 180,0,180. adding 90,0,0 to both gives different results. if your rotated this way in one you might be standing facing someone, in the other your butt is facing them and your on your head.

that's why you can't really convert because when your converting down from quan do you convert to 180,0,180 or 0,180,0.

Quaternions are better, they don't suffer from gimbal lock for example is the big thing.

basically eulers have 3 angles and 3 axes.

quaternions have a single axis and rotate around it.

(as i understand it, quats are complex numbers, there great for computers, horrible for humsies)

as such your best thing to do is use quaternions.

otherwise convert to 0-90 from 0-1 and then feed into quaternions.euler I suppose.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Rotate angle between two points 0 Answers

how to convert the angle to roatation? 1 Answer

How Do I accurately rotate a player 180 degrees about the Z axis? 1 Answer

Make a side of an object LookAT another object 1 Answer

Rotate floor plane in-game via C# script 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