Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by zedseven · Sep 04, 2016 at 02:10 PM · quaternionangleaxis

Quaternion.AngleAxis Providing Weird Results

I'm sorry if this question has been asked before, but I can't find a solution or answer, so I'll ask here:

I'm working on a simple Universe generator which generates stars, then planets. I've got the star generation down, but when generating the position for the planets, I'm having some troubles.

I generate a random orientation for the main orbit ring with

 Vector3 orbitRingRot = new Vector3(0, 1, 0);
 orbitRingRot = Quaternion.AngleAxis(Random.Range(0.0f, 360.0f), Vector3.up) * orbitRingRot;
 orbitRingRot = Quaternion.AngleAxis(Random.Range(0.0f, 360.0f), Vector3.right) * orbitRingRot;
 orbitRingRot = Quaternion.AngleAxis(Random.Range(0.0f, 360.0f), Vector3.forward) * orbitRingRot;

and then when creating the planet position, I use (planetGenDist is an arbitrary float distance value):

 Vector3 planetPos = starPos + ((Quaternion.AngleAxis(Random.Range(0.0f, 360.0f), orbitRingRot) * Vector3.up) * planetGenDist);

The idea is to generate planets around the star at varying distances and places on their orbits on one flat plane. This code ends up with results like alt text

whereas they should form as a flat disc, of sorts. I guess what I'm asking is: Why does this code generate cones? These cones vary in their angles as well - I do get some flat discs, but I also get extremely narrow cones.

unityanswershelpimage1.png (125.4 kB)
Comment
Add comment · Show 1
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 Owen-Reynolds · Sep 04, 2016 at 06:47 PM 0
Share

I think you're using angles in the wrong order: ZXY when you want the standard YXZ. Take a look at http://answers.unity3d.com/questions/810579/quaternion-multiplication-order.html (one answer is $$anonymous$$e, so I don't retype it here.)

Rotation math is tricky. In this case, just Quaternion.Euler(random, random, random) seems like it would do what you want. But I don't see where the "on a flat plane" orbits apply, so what do I know.

0 Replies

· Add your reply
  • Sort: 

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

53 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

Related Questions

Need help understanding Quaternion.AngleAxis 0 Answers

What's the reverse of Quaternion.AngleAxis? 0 Answers

How can I find direction with known 2 projection angles on xz and yz planes? 2 Answers

the reverse operation of Quaternion.AngleAxis? 1 Answer

Gimbal Lock Problem 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