2022 Developer Survey is open! Take survey.
24 votes
Accepted

Using Quaternions: What can I do with them? (without the maths)

Multiplication At least in terms of Unity's implementation of Quaternions, the multiplication order described in the question is not correct. This is important because 3D rotation is not commutative. ...
user avatar
  • 113k
15 votes

Using Quaternions: What can I do with them? (without the maths)

Where's the dot product used? In Unity, one of the most common users of the dot product is whenever you check if two quaternions are equal via == or ...
user avatar
13 votes

Rotating an object with quaternion

You should probably use glm::angleAxis() (documentation here): ...
user avatar
  • 23.4k
12 votes

How can you visualize a quaternion?

One of the visualization methods I like is to represent quaternion (orientation in 3d space) as vector (x,y,z components) + spin (the rotation around that vector, stored in w component). If you are ...
user avatar
10 votes
Accepted

Is adding quaternions a useful operation?

I can think of two reasons: if your quats represent infinitesimal rotations, adding them together actually yields the composite rotation, provided the result is infinitesimal too (i.e. an element of ...
user avatar
  • 3,221
6 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 ...
user avatar
  • 113k
6 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 ...
user avatar
  • 113k
5 votes
Accepted

Unity - Quaternion - Rotate / Unrotate Error

This is a late response, but I figured this question illustrates a common problem that many people are likely to run into and that deserves an answer. Quaternion rotation uses half the angle you want ...
user avatar
  • 166
5 votes
Accepted

Quaternion rotation problems

"Is it wrong that I am counting total rotation and then creating [a] quaternion from it?" Yes, because rotations do not combine like simple addition. (In mathematical terms, rotations in three ...
user avatar
  • 113k
5 votes
Accepted

Unwanted roll when rotating camera with pitch and yaw

As I explained above, this is not an issue with quaternions. Quaternions just represent your rotation. The problem is that you have mutually conflicting goals for this rotation: The camera can look ...
user avatar
  • 113k
5 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 ...
user avatar
  • 113k
5 votes
Accepted

Direction vector to quaternion

From http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/ ...
user avatar
  • 3,669
4 votes
Accepted

Quaternion Rotation - Clockwise or Counter-Clockwise?

It depends on the coordinate system you're working in. In a right-handed coordinate system (eg. x right, y up, z points toward the viewer), the right-hand rule applies, as mklingen describes in the ...
user avatar
  • 113k
4 votes
Accepted

Convert vector interpolation to quaternion interpolation? (Catmull-Rom)

Since it seems acceptable, I’ll go for the following suggestion: just interpolate the quaternion components, then normalise the resulting quaternion. pro: it’s fast and the code is short pro: and ...
user avatar
  • 23.4k
4 votes
Accepted

Explaining vector math for a pendulum camera

The three component vectors right, up, and forward probably point along the axes ...
user avatar
  • 5,454
4 votes
Accepted

Rotating an object with quaternion

the glm::quat(float, float, float, float); constructor doesn't do what you think it does. It sets the values directly. The values of the quaternion ...
user avatar
4 votes
Accepted

Unity's Quaternion.Lerp slows down when target is directly behind turret

Taking a look at your barrel rotation function... ...
user avatar
  • 113k
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 ...
user avatar
  • 113k
4 votes

Convert quaternion to a different coordinate system

Summarizing your two coordinate spaces: ...
user avatar
  • 113k
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-...
user avatar
  • 14.5k
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 ...
user avatar
  • 23.4k
4 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 ...
user avatar
  • 113k
4 votes

Combining Quaternion Rotations

Multiplying two quaternions gives you a quaternion equivalent to performing the two rotations they represent in sequence. ...
user avatar
  • 113k
4 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 ...
user avatar
  • 318
3 votes

Quaternion Rotation Help

I'd expect the conversion to be more like: ...
user avatar
3 votes
Accepted

How do I create a camera?

Ok, I'll give it a shot... Your camera will need much of the same functionality as your regular entities in the game. Specifically, it will need to have both a position and orientation in your game ...
user avatar
  • 217
3 votes
Accepted

How to compute the forward, up and right vectors from a single quaternion?

You can simply apply the quaternion to the (0,1,0) (0,0,-1) and (1,0,0) vectors for up forward and ...
user avatar
3 votes
Accepted

Unity 3D - Rotate towards object with random offsets

I found the solution myself. Here's what I've done: I took the default forward rotation of the firingPoint object, and split it into it's parts - ...
user avatar
  • 321
3 votes
Accepted

How should I handle quaternion types, in my game engine?

If your goal is to have quaternion that expresses rotations, and if you want to do operations with them (for eg. rotation composition by multiplying quaternions or convertion a quaternion to a ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible