First I am Korean. I feel sorry that my English writing can be difficult to understand T_T…
My questions are below.
-
If I input some rotation values on inspector, in what order rotation occurs? I think if I change rotation values on inspector, I cannot use Quaternion because I cannot know a rotation vector by inputting some values on inspector. If I am wrong, how do I know the rotation vector by inputting some euler values on rotation on inspector?
-
I see that there is difference in rotation’s axis and transform’s axis. Why are their axis direction different?
-
If I am right on question 1, inputting rotation values on inspector make Gimbal lock because there is ‘order’ for rotating, right? I guess the calculation process using Quaternion would be like below. Am I correct in guessing?
S: source unit rotation vector
O: objective unit rotation vector (that I want to rotate toward)
S * O: inner product of ‘S’ and ‘O’ (cos@) (@ means euler angle between S and O)
s x o: outer product of ‘S’ and ‘O’
-
In S*O, get @ by using arcCos(@).
-
In S x O, Get a vector and normalize it. normalize(S x O) = axis’
-
Use (cos(@/2), cos(@/2) * axis’) to rotate ‘S’. (qpq*)
(cos(@/2) means rotation w, cos(@/2)*axis’ means coefficient of x,y,z)
If you cannot understand my writing, feel free to ask me!
Thank you for reading in patience!
Hi @KimDaeEon, to answer your questions:
-
The order you enter the rotation angles into the inspector is the order they are performed in.
-
Rotations are always performed based on the Transform’s Local Axis orientation. However, the Transform Axis you see in the Editor’s Scene view can either be viewed as Local or Global - you can click the ‘Local’ or ‘Global’ button in at the top left of the editor window to switch between them. When you view the Axis as Global, it is shown aligned with the World Axis.
-
You get Gimbal Lock whenever two rotational axes align with each other. Best not to use Euler angles at all if possible. Quaternions are not too difficult to deal with.
I’m not sure I understand what you want to do in your code:
When you multiply Quaternions, say S * O, it has the effect of adding rotation O to S. In other words, take existing rotation S and rotate it further by rotation O.
From there, I don’t understand what you are trying to do.
If you want to convert a Quaternion into a direction vector, simply multiply it by an Axis vector: If S is some rotation, and you want to know what direction S represents with respect to the z Axis, you can just get Vector3 direction = S * Vector3.forward. From there, it’s easy to get the Angle between direction and forward: Float angle = Vector3.Angle( direction, Vector3.forward), for example.
If you could explain more clearly what you are trying to do, maybe I could help further.