8
votes
Accepted
Converting a quaternion in a right to left handed coordinate system
A quaternion can be thought of as an angle-axis representation:
quaternion.xyz = sin(angle/2) * axis.xyz
quaternion.w = cos(angle/2)
So, converting them between ...
7
votes
Switch axes and handedness of a quaternion?
To convert the Quaternion, we need to convert the imaginary part (xyz) which represents the axis of rotation into the destination coordinate system. In this case, that means exchanging x & y while ...
7
votes
Accepted
Rotate from Current Rotation to Another using Angular Velocity
"maybe due to the gimbal nature of Vector3 for angular velocity" ...using Vector3 for angular velocity does not entail gimbals, but converting it to Euler angles does.
Angular velocity is ...
6
votes
How to express and verify euler rotation limits in Unity
Euler angles aren't necessarily a good way of expressing limits over arbitrary ranges, as their behaviour close to zero is very different from their behaviour away from zero.
Below I've visualized ...
6
votes
Accepted
Direction vector to quaternion
From http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/
...
6
votes
Unity Quaternion.LookRotation meaning
Quaternion.LookRotation(forward, up) constructs an orientation quaternion that...
rotates an object's local z+ axis (0, 0, 1) — the blue arrow on its local ...
6
votes
Accepted
Euler angle and Quaternion conversion become weird when yaw is bigger than 90 degrees
Your current code assumes it's always going to get Euler angles where x is between ±90° and z is close to 0.
Meanwhile, glm wants to return Euler angles that are standardized so that y is between ±90°,...
6
votes
Combining Quaternion Rotations
Multiplying two quaternions gives you a quaternion equivalent to performing the two rotations they represent in sequence.
...
5
votes
Convert quaternion to a different coordinate system
Summarizing your two coordinate spaces:
...
5
votes
Does gimbal lock occur only when a combination of local and world rotation axis are used?
Gimbal lock occurs when your internal structure for storing/composing rotations uses a gimbal model:
Image via Wikipedia, attributed: "By Lookang many thanks to Fu-Kwun Hwang and author of Easy ...
5
votes
Accepted
Understanding how to use Quaternion to rotate object
Explaining why quaternions work the way they do and their relation to mainstream linear transformation rotations would require some more advanced mathematics knowledge regarding group theory and how ...
4
votes
Accepted
LookRotation() make X axis face the target instead of Z
I've answered a few flavours of this before.
The basic idea is to chain together two rotations: one that takes the axes you want to align and points them along z+ and y+ respectively, and then the ...
4
votes
Accepted
How to smooth rotations?
Yes, in fact that's what quaternions are often used for - interpolating between two different orientations. Other methods of representing orientation suffer from issues like gimbal lock and wrap-...
4
votes
Accepted
Storing transformations in game objects. (GLM, C++)
My general recommendation is to keep both the source components of your transformation for ease of manipulation:
local translation vector
local orientation quaternion
local axis-aligned scale triplet, ...
4
votes
GLM conversion from euler angles to quaternion and back does not hold
The results are not what you expect, but they are not wrong. It’s just that for a given orientation there are at least two “paths” through Euler angles that lead there.
For instance, the identity ...
4
votes
Accepted
How does Unity know where the character is facing?
It doesn't know.
What it does is point the local z axis of the object (that's the blue arrow you see in the scene view when selecting its local transform gizmo) in the ...
4
votes
Accepted
How does Unity's FromToRotation work? A major part of its behavior seems undocumented
FromToRotation chooses the shortest possible rotation that maps fromDirection to toDirection....
3
votes
Accepted
Euler (right-handed) to Quaternion (left-handed) conversion in Unity
Three points we need to consider:
Matrices and quaternions in Unity multiply from right to left, if we think of each subsequent rotation being applied with regard to the world axes:
...
3
votes
Accepted
Relative quaternion rotation (delta rotation) produces unstable results
Thanks to Neal on Mathematics Stackexchange I found out that my code to calculate relative rotations was indeed in the wrong order (I took it from Unity Anwers which seems not to be the correct way to ...
3
votes
Applying angular velocity to quaternion
In the following I use a vector hat to represent a quaternion and a unit vector hat to represent a unit quaternion.
Let q(t) represent the quaternion rotation at any point in time. Let r be a ...
3
votes
Rotating according to ground normal on Unity 3D
Nevermind guys. I just realized a really silly mistake behind all of this. The thing is, when I use:
...
3
votes
Unity Quaternion.LookRotation meaning
I am not sure what you mean with "modify the X axis". If you intend to do transform.rotation.x = value, then you are going to fail, because quaternions are not that ...
3
votes
Finding rotation quaternion from orthonormal basis?
@Andrew Tomazos is correct, but conversion of the three vectors to a matrix first requires the storage of 16x additional floats, and is a bit slow.
A better solution is found by writing out the basis ...
3
votes
Accepted
What is Unity Quaternion range?
Rotations and orientations in Unity are represented by unit quaternions.
That means a quaternion \$(w, x, y, z)\$ where:
$$w^2 + x^2 + y^2 + z^2 = 1$$
You can see this means each component is in the ...
3
votes
3D Camera Rotation (Unwanted Roll) - Space/Flight Cam
It seems like you accumulate transformations. What you need to do instead is to keep rotation as euler angles pitch and yaw and then calculate final rotation from them.
3
votes
Accepted
LookRotation function for Z-up, right handed system
First, we can transform your coordinates into Unity's coordinates:
...
3
votes
Accepted
How do I increment a quaternion rotation in update()?
Applying the rotation that a quaternion represents is done via multiplication. This is really neat, because it works on vectors, like so:
v2 = q * v1
but also on ...
2
votes
Quaternion based camera pitch freaking out, and Z-axis drift
Firstly, I would recommend working in radians, not degrees. Whilst the GLM library can work with degrees, it was designed with radians in minds(this is a very minor issue though, so work with what you ...
2
votes
How to compute the forward, up and right vectors from a single quaternion?
What I believe @ratchet freak means when he says "apply" is to rotate each of the original front, right and up vectors around the orientation quaternion. I'll just leave this implementation based off ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
quaternion × 393rotation × 207
unity × 136
mathematics × 70
c# × 56
3d × 39
camera × 37
vector × 37
opengl × 31
c++ × 27
transformation × 26
matrix × 24
glm × 23
xna × 19
euler-angles × 19
directx × 12
angles × 12
physics × 11
interpolation × 10
orientation × 10
java × 8
animation × 8
javascript × 8
movement × 8
three.js × 8