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 /
This question was closed Jun 11, 2017 at 02:57 AM by D3Duck for the following reason:

The question is answered, right answer in comments

avatar image
0
Question by D3Duck · Jan 13, 2016 at 03:52 PM · rotationtransform.rotation

Multiplying Quaternion.Euler(0f,0f,0f);

I've been trying to figure out how to add a Quaternion rotation to another one. I found that multiplying quaternions is in actual fact adding them together. But in my code that doesn't work and it also doesn't make sense to me. Since when a quaternion is 0, how could it be multiplied and result in anything else than 0?

 Quaternion q1 = Quaternion.Euler(0f,0f,0f);
 Quaternion q2 = Quaternion.Euler(0f,10f,0f);
 q1 *= q2;

This would always result in q1 still being 0, right? So how would I add 10 degrees to the Y axis in this case?

What I'm trying to do in my code is add q2 to q1 and then set this Quaternion to the rotation of a Transform, then add q2 again etc. Thus incrementing the rotation.

Can anyone shed some light on what I don't understand here?

Comment
Add comment · Show 8
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 jni97 · Jan 13, 2016 at 04:31 PM 0
Share

I don't really understand what you exactly want, but i think you should use q1 = Quaternion.Euler(0f, q1.y + 10f, 0f); This would add 10 degrees to the y-angle everytime you call it

avatar image Bunny83 jni97 · Jan 13, 2016 at 05:57 PM 0
Share

No, no, no ^^ That's completely wrong :) the "y" component of a quaternion doesn't contain an angle. A quaternion doesn't work with eulerangles at all. The static method "Euler" converts eulerangles into a quaternion.

avatar image Bunny83 · Jan 13, 2016 at 06:05 PM 1
Share

@D3Duck:

Quaternions are quite complicated. They aren't just some eulerangles. They represent a 4 component complex number. The identity quaternion doesn't have the values 0,0,0,0 as the quaternion is usually a unit quaternion so it always has a length of 1.

You shouldn't be bothered how quaternions work. If you do:

  q1 *= q2 // which is the short form of q1 = q1 * q2

You will rotate q1 by q2

http://de.mathworks.com/help/aeroblks/quaternionmultiplication.html

avatar image jni97 Bunny83 · Jan 13, 2016 at 06:09 PM 0
Share

Yeah of course, I forgot to write it^^

avatar image Owen-Reynolds · Jan 13, 2016 at 06:18 PM 1
Share

Two things: Quaternion.Euler(0,0,0) isn't an all-zero quaternion -- it creates a Quaternion from angles x=0, y=0, z=0. That Quaternion isn't all zeroes. new Quaternion(0,0,0,0) would be an all-zero quaternion (which I think is just a garbage value.)

But more importantly, * is just a symbol. For classes and structs, it does nothing until you overload it, and than it does whatever you want it to do. q1*q2 is really calling the function Quaternion.add(q1, q2).

As to why mathematicians use multiply to add them, ins$$anonymous$$d of +, they just felt like it. But, for real, the "add angles" equations involve times and plus, but more times, so they used that symbol for it (I think.)

avatar image D3Duck Owen-Reynolds · Jan 13, 2016 at 07:28 PM 0
Share

Thanks for the reply, this clears up a lot

avatar image Bunny83 Owen-Reynolds · Jan 14, 2016 at 04:18 AM 1
Share

Uhm, no :) You actually are multiplying the two quaternions together. An addition would be pointless for rotations. The multiplication is called the Hamilton product. Since Quaternions are essentially some sort of complex numbers the product works very similar.

While complex numbers only have one imaginary part, quaternions have three. The special relation between those three imaginary number actually make the product non commutative. Quaternions behave like matrices though are smaller and easier to manage. If you have two rotation matrices you have to multiply them together to get a combined rotation matrix.

So the multiplication of two quaternions has nothing to do with adding. Unity's quaternion struct doesn't even implement an "Add" method as it has no use when dealing with rotations.

avatar image D3Duck Bunny83 · Jan 15, 2016 at 03:45 PM 0
Share

Thanks again for your answers, this actually helped me a lot. I finally know how to deal with these things now.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

37 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

Related Questions

I can't coexist by character direction of camera vector AND character rotate by Input 0 Answers

Rotation noob help please!!! 0 Answers

Rotating an object between two positions?? 0 Answers

Rotating game object 1 Answer

Rotating an Object (To Face Another Object) Only on X and Y Axis 3 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