Comments and answers for "Quaternion multiplication order"
http://answers.unity.com/questions/810579/quaternion-multiplication-order.html
The latest comments and answers for the question "Quaternion multiplication order"Comment by Owen-Reynolds on Owen-Reynolds's comment
http://answers.unity.com/comments/1805238/view.html
Sure, but now you're explicitly changing position, and bringing in a vector. I _think_ the point was that by themselves, rotations are only around the gameObject's origin.Fri, 15 Jan 2021 03:55:49 GMTOwen-ReynoldsComment by remi07 on remi07's answer
http://answers.unity.com/comments/1805228/view.html
"that by applying varying rotations on the transform, without that object having a parent, and even then you have to rotate the parent, not the object itself. If you were to try to rotate the object "around the world axis Y", it would simply spin in place around the up and down axis in the world. Not spin around 0,0,0's Y axis."
I don't think I agree? Ie if an object is at transform.position away from 0,0,0. Say its walking at the surface of a planet. Then to make it spin along the Y axis (or Vector3.up) you just need to do
newPosition = Quaternion.Euler(Vector3.up * angle) * transform.position;
You don't need a parent?Fri, 15 Jan 2021 02:08:21 GMTremi07Comment by Owen-Reynolds on Owen-Reynolds's answer
http://answers.unity.com/comments/1720259/view.html
You're assuming that we care about either the object's current rotation or a possible parent's. Often we don't -- we have 2 arbitrary rotations to combine. We often aren't even using the result to rotate a gameObject -- it's part of some other equation.
Your examples of "rotate an object" and "set child rotation" are just 2 of the many things we might use lhs*rhs to do.Sun, 19 Apr 2020 17:38:48 GMTOwen-ReynoldsComment by Owen-Reynolds on Owen-Reynolds's comment
http://answers.unity.com/comments/1720256/view.html
Try asking this as a separate Q. Possibly break it down, for example "convert euler zyx into Unity eulers". Forums also has a dedicated area for VR. "How to use VR software package X" seems fine for that.Sun, 19 Apr 2020 17:32:48 GMTOwen-ReynoldsComment by EricHFrazer on EricHFrazer's answer
http://answers.unity.com/comments/1720082/view.html
the thing that is killing me personally, comprehension wise, is this: I have some stereo camera calibration rotation matrices. One for the L camera, one for the R. Both the rotation matrices are in LH coordinate systems... They tell the cameras which way to rotate compared to the headset, in order to have the images be perfect. Now, I run the images through some openCV software, which is RH-based, and determine according to openCV, that the L camera needs to be rotated an extra $$anonymous$$atrix4x4, call it $$anonymous$$, in order to be correct. I need to figure out how to translate this RH-based OpenCV matrix's angles to angles Unity can understand. I don't know the best way to decompose the $$anonymous$$ matrix into rotation angles around X, Y, and Z, and in what order. And once I have those values, I'm not quite sure how to construct a quaternion out of them in order to get that applied to the L camera object in Unity. It's a real stumper. I think OpenCV calculates 4x4 $$anonymous$$atrixes with Rout = Rz * Ry * Rx. And Unity calculates Quaternions and its 4x4 matrices using Ry * Rx * Rz. (?)Sun, 19 Apr 2020 07:34:47 GMTEricHFrazerAnswer by EricHFrazer
http://answers.unity.com/answers/1720080/view.html
I posted this earlier, then got so annoyed at the comments, I deleted it. I'm going to repost and try to be more concise... I'm going to get to the point first, then explain some things afterwards.
Suppose you have an object "O" and want to rotate it by a quaternion Q. You need to decide if you want it to rotate around the world axis, or the object's own local axis. (Most of the time I want it to rotate around its local axis)
W: O.transform.rotation = Q * O.transform.rotation <- this rotates around world axis
L: O.transform.rotation = O.transform.rotation * Q <- this rotates around its local axis
That's it. Those are the two forms you need to remember. The way I remember the order is because (as the docs say), when Unity runs across A mul B, the * operator override performs the A rotation first (LHS), then applies the B operation next (RHS). In my head I phrase it "gives it an extra spin at the end of everything". Iif you give it the extra spin before its normal spin, that's not going to happen "locally". That's a global (world) spin.
Another sort of non-obvious result of this is that if you have a cube at a distance from 0,0,0, and you want to rotate it in a giant circle around say the Y axis, like a planet, you can't do that by applying varying rotations on the transform, without that object having a parent, and even then you have to rotate the parent, not the object itself. If you were to try to rotate the object "around the world axis Y", it would simply spin in place around the up and down axis in the world. Not spin around 0,0,0's Y axis. Obvious to some, but not to everybody.
----------
Somebody wrote me a private message and said, "you don't know what you're talking about wrt local rotations and parents. Nothing in Unity when it comes to setting rotations and positions matters with regards to if it has a parent or not". So polite. Well, it's true and it ain't true. Let me explain...
----------
Put two identical objects into a scene. One of them has a parent, one of them does not. The one with a parent, the parent has some non-zero position and rotation offset. I set both the objects' *world* position and rotation to something interesting. I can do it via independently setting position and then rotation, or I could call SetPositionAndRotation. Both the objects end up in exactly the same world position and world rotation. So what's the difference? The difference is that under the hood, during the = assignment for both position and rotation, Unity peeks at where you want it to be, and calculates where it already is (by looking at the parent chain), and it calculates deltas, and sets the *local* component to whatever it needs to be in order to get the object to where it should be. This applies to position AND it applies to rotation. In fact, rotation is "a bit special". When you assign a world rotation to an object that has a parent, it will change *both* the local position and the local rotation to get the object to the exact spot you've told it to be at. I find this interesting...Sun, 19 Apr 2020 07:27:52 GMTEricHFrazerComment by Owen-Reynolds on Owen-Reynolds's comment
http://answers.unity.com/comments/1720015/view.html
If you have both rotations around y, such as Ry1 and Ry2, then Ry1*Ry2 is just adding the y-rotations. It's a super-easy special case. In math. that's called a _degenerate_ case. If only 1 is around y, it's as complex as all the rest.Sun, 19 Apr 2020 00:09:56 GMTOwen-ReynoldsComment by winxalex on winxalex's comment
http://answers.unity.com/comments/1720013/view.html
Quite degenerative when in your answer you also have Ry. which maybe mean rotation around y,x? Right?. Order of what? A * B not equal to B*A where A,B are Quats
Good answer can be found here.
https://gamedev.stackexchange.com/questions/140579/euler-right-handed-to-quaternion-left-handed-conversion-in-unitySat, 18 Apr 2020 23:58:30 GMTwinxalexComment by Owen-Reynolds on Owen-Reynolds's answer
http://answers.unity.com/comments/1681200/view.html
You seem to always have both rotations around y. That's a degenerate, easy, case where the order doesn't matter. To see what the question is asking, take any other rotations -- like around y and x.Sat, 30 Nov 2019 21:15:27 GMTOwen-ReynoldsAnswer by winxalex
http://answers.unity.com/answers/1681170/view.html
SUPER SIMPLE:
![alt text][1] ![alt text][2]
//Note: Rotation values in Inspector are in Local space
//Let say Quaternion is something that contain information of how some 3D object is rotated
//for simplicity we will use just rotation aroundY and let say we have one parent game object and one child
//let parent is rotated 60 degree, and child is 30degree.
//as parent is first element in the world and world is not rotated it has same global and local rotation represented by Quaternions
//parentGO.transform.rotation==parentGO.transform.localRotation
//child has 60degree rotation from parent and 30 itself so it has 90 degree global rotation, and 30 local as we said
//childGO.transform.rotation.eulerAngles.y will be 90
//childGO.transform.localRotation.eulerAngles.y will be 30
//When we use multiply 2 Quaternions A * B,
**//Think Quaternions A * B as addition: of A+B=C, if A gives rotation of 60 and B of 30, A*B will give rotation of 90 degree
//Think of A as global rotation (transform.rotation) or as quaternion value, delta offset for B (delta + B)
//Think of B as local rotation (transform.localRotation) or quaternion value, delta offset for A (A + delta)**
//so to find out child global rotation
// parentGO.transform.rotation * childGO.transform.localRotation; // 60+30=90 gives you quaternion that will rotate something 90degree
// if Quaternon gives you rotation, inverse quaternion gives you minus rotation, ex. if A=60, Inverse(A)=-60
//but what if we have child global rotation which is 90 in our case, and we want to find child local rotation
//Quaternon.Inverse(childGO.transform.parent.rotation) * childGO.transform.rotation; // (-60 + 90 = 30)
//(delta + B)
//so what if we want to rotate childGO locally for 10degree more, was 30, so plus 10 will be 40
//childGO.transform.localRotation = Quaternion.AngleAxis(10, Vector3.up) * childGO.transform.localRotation; //(10+30)=40
//(A + delta)
//so what if we want to rotate childGO globally for 10degree more, was 90degree, will be 100
//childGO.transform.rotation = childGO.transform.rotation * Quaternion.AngleAxis(10, Vector3.up); //(90+10)=100
[1]: /storage/temp/149392-clipboard24.jpg
[2]: /storage/temp/149393-clipboard25.jpgSat, 30 Nov 2019 17:01:48 GMTwinxalexComment by chris-nolet
http://answers.unity.com/comments/1376424/view.html
The documentation has been updated, and now reads: "Rotating by the product `lhs * rhs` is the same as applying the two rotations in sequence: `lhs` first and then `rhs`, relative to the reference frame resulting from `lhs` rotation." As Owen-Reynolds points out in his answer, below, it is left-to-right if you think of each transform being applied as a _local rotation_. If you want to think about applying transforms 'as if you're using the global rotation tool,' read it right-to-left ins$$anonymous$$d.Mon, 10 Jul 2017 02:01:07 GMTchris-noletComment by chris-nolet on chris-nolet's answer
http://answers.unity.com/comments/1376421/view.html
Can confirm: You have the order correct. (No need for the final paragraph/disclaimer.)Mon, 10 Jul 2017 01:53:34 GMTchris-noletComment by Oliver-Bogdan on Oliver-Bogdan's answer
http://answers.unity.com/comments/1368485/view.html
Great explanation, got to save this somewhere :)Wed, 21 Jun 2017 14:02:29 GMTOliver-BogdanComment by slippdouglas on slippdouglas's answer
http://answers.unity.com/comments/1216770/view.html
Your logic of _“applying A as a global rotation to B. Or as applying B as a local rotation to A”_ matches my own findings. I believe you can remove the _“I always get the orders mixed up”_ footnote.Sat, 16 Jul 2016 01:35:27 GMTslippdouglasComment by user132456789 on user132456789's answer
http://answers.unity.com/comments/811056/view.html
Thanks. Nice explanation.Fri, 17 Oct 2014 07:32:58 GMTuser132456789Answer by Owen-Reynolds
http://answers.unity.com/answers/810719/view.html
Combining rotations (and using Quaternions) is one of those things where Unity just copies the way everyone else does it. So you can find better descriptions in general gaming-math sites.
The missing piece is local vs. global. If you have rotations `A*B` you can think of it as applying A as a global rotation to B. Or as applying B as a local rotation to A(*).
In other words, suppose R is the current rotation, and Ry is a small spin on Y, which you would like to apply. To apply it as if you're using the global rotation tool, use `Ry*R`. To apply the spin as if using the rotation tool set to local, use `R*Ry`.
In other, other words. `A*B` is B applied on local A, or global A applied to B, depending on how you want to think of it. Yes, it is very confusing until you settle on the "right" way to think of it for any particular problem.
Robot hand is a common example. To find the rotation of a hand bone, use globalRbotSpin * localShoulderSpin * localElbowSpin ... . All rotations are stored and applied locally.
(*) I always get the orders mixed up, and my Unity machine isn't here. It could be the other way -- left is local and right is global.Thu, 16 Oct 2014 16:47:20 GMTOwen-Reynolds