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 Karsnen_2 · Jul 13, 2012 at 02:11 PM · c#iosinputquaternion

How good is my "Quaternion" code efficiency?

Hello,

I have been working around Quaternions and I have a single piece of Quaternion code which seems to be the base for all the operations in my iPad game. I would like to know whether my code is efficient considering for the entire life-time of the project.

Kindly do let me know if it would cost issues in the future.

 reqAngle = new Quaternion ((Input.gyro.attitude.y), 0 , -(Input.gyro.attitude.x), reqAngle.w);


Code Description:

  •   reqAngle is a Quaternion variable set to identity in the start call. 
    
    
  •   I get the Input through gryo and not through accerleration and this forms the base for the main Input gateways for the entire project. 
    
    

My main concern is "Quaternions".

Thank you & Please.

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 Kryptos · Jul 13, 2012 at 02:28 PM 1
Share

Yes but this may not work: see my answer.

I will "appear" to work because you are in a special case where one component is zero. But the angle variation will not be linear, unless you know how to recompute the w-component. But in this case you are just reinventing the wheel.

avatar image Karsnen_2 · Jul 13, 2012 at 03:04 PM 0
Share

@kryptos - I have one answer from Nicolas, is that you?

Thanks guys. I might have to find another way then. I will have to see. Is there any tips you guys could give me.

I am trying to control a falling object. Hence, my plane is x and z. So I move in a 2 - dimensional way (XZ). Could give me an idea where I could rotate the object?

Like you see my code above - I get the input and apply to the rotation.

Thanks guys.

1 Reply

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

Answer by Kryptos · Jul 13, 2012 at 02:26 PM

The quaternion first three values, although called "x", "y", and "z" have nothing to do with the base axis or the three rotations along those axis. They are complex numbers living in a mixed 3D-imaginary space and a 1D real space.

Quoting Unity documentation:

However, they are based on complex numbers and are not easy to understand intuitively. Thus you almost never access or modify individual Quaternion components (x,y,z,w)

You need to use the other methods from the Quaternion class, such as Quaternion.AngleAxis.

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 Karsnen_2 · Jul 13, 2012 at 03:05 PM 0
Share

NIcolas, that documentation lead to the concern actually. Thanks man. I will have to look into other options and try to find a way.

First - Quaternion.AngleAxis.

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

[Solved] Help on a rotation issue for a Top-Down view? 1 Answer

[SOLVED] Derive an equation from a graph? 1 Answer

How to create a damped harmonic oscillation? 1 Answer

Audio: how do I immediately play a new audioclip without delay(code included)? 2 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