# Questions tagged [quaternion]

Mathematical constructions, number systems. In 3D-graphics quaternions are used alongside vectors and matrices. One of the benefits of quaternions is that they overcome some rotational problems (known as gimbal locks) that are inherent to vectors and matrices.

389 questions
Filter by
Sorted by
Tagged with
1 vote
41 views

### Quaternion.Euler acting weird

so I'm building up a simple arcade racing game and I was messing around with the Wheel Colliders setup. I was wondering if it was possible to add some camber adjustments in real time depending on the ...
86 views

### Comparison of 2 different quaternion axes

I am trying to compare the Z-axis and the X-axis of two different quaternions in a way that would give me the Euler angles about the X and Y axes to line up the two different axes. In my program, the ...
195 views

### Why are Quaternions better than Euler-Angles for Godot (when to use which)?

Sorry about the click-bait, I know there are many many reasons why Quaternions and Bases are better than using Euler-Angles. Anyone on a 5 second google search could easily know why! But I am trying ...
74 views

### How to rotate spaceship quaternion to face target direction with constant angular speed?

I have an enemy spaceship, and I want to make it turn to face the player with (for now) a constant angular speed. The ship's orientation is a quaternion. How do I do this? Since this is totally free ...
• 111
63 views

### How to get difference in rotation between 2 objects, but only on one axis

Say I have 2 cubes that start with the same rotation. I wish to track the rotation difference between the 2 about the z (forward) axis. Such that if cube A remains stationary and cube B rotates 30 ...
36 views

### Usage of 'World rotation quaternion'?

While debugging the code that decomposes the world matrix, I found that the decomposed world rotation value is different from the world rotation value stored in Transform. Simply, World Rotation is ...
154 views

### Correct order on accumulating rotations

Suppose I have an Arcball camera that rotates up/down and sideways based on mouse input. After doing some research, I discovered that the correct way of calculating the new orientation is to do it the ...
62 views

### Quarternion rotation flattening cube

I am trying to rotate a cube using a quaternion matrix with WGPU. However, whenever I try to rotate it, I end up with I am using the matrix from https://en.wikipedia.org/wiki/...
103 views

### Smartphone tilt calculation when using gyroscope in Unity (smartphone moving problem)

I have been trying for several days now to set up the correct behavior of the gyroscope in Unity. I want to make it so that when the smartphone is tilted, the object tilts along the z-axis. I found ...
45 views

### Orient a player mid-air to their predicted landing orientation in Unity?

Ever played Skate 3? When dropping into a ramp, or if you're midair, your player's up direction aligns to the normal of the surface you're about to land on, while respecting the player's forward ...
161 views

### 3D First person Rotate Character Unity

I'm facing the problem that my chacter is spinning around itself when I try to move, that's because Im trying to make my player move in the direction of the camera, but when I move it keeps rotating ...
345 views

### Convert a quaternion from NED right handed to ENU left handed

My drone's camera rotation is calculated using NED Right handed quaternion and I want to convert it to ENU left-handed.
1 vote
174 views

### How do you rotate an object that uses a quaternion to represent orientation in 3D from a 3 vector input with values from a gamepad?

I'm using unity3d to create a six-degree of freedom flying game. The game takes in input from a standard dual-stick gamepad (like the Logitech f310). In unity each of the gamepad's joystick's axes are ...
• 37
47 views

### Visualising quaternions for key frames in an editor

I'm working with 3D models from an existing game with its own proprietary file formats, however the way they work is pretty standard: Skeleton is defined as a set of bones, each bone either has a ...
190 views

### How to rotate a player to orient their up with a landing normal?

I'm making a skateboarding prototype in Unity, and like in skate 3, I'd like the player to sort of "align" gradually to their predicted landing slope. I've written the code that gets the ...
154 views

### glm::eulerAngles gives unexpected output for quaternion

I used the euler->mat4->quat to give the right result, but euler->quat gives the wrong result - is there something I did wrong? ...
1 vote
24 views

### I have a wind simulation in Unity, and i need to rotate an arrow to show the wind direction [duplicate]

I have this code that creates random vectors, which are used in the AddForce to push rigid bodies around. ...
• 31
495 views

### How can I calculate the translation used for rotating an object with a quaternion in Unity, to use for OpenGL?

In Unity, whenever I rotate an object, it also performs a translation. If I simply try to draw a quad with the quaternion used in Unity, it appears off because of that missing translation unity ...
33 views

### How can I rotate 2 objects based on connection points?

I have 2 objects, each with GameObject children which are empty objects that I call snap points. These snap points represent where the original objects can connect together. They are positioned to ...
56 views

### How to encode homogeneous transformations on the root node of a gltf

Let us say we have a gltf asset. Let us say we want to apply an arbitrary linear transformation to the root node. We will say that the root node has a rotation, translation and scaling components. For ...
• 260
189 views

### 6DoF camera control with a toggleable gimbal/horizon line lock and auto-upright button

I have a smooth 6DoF controller from following a tutorial (this is the tutorial) and tweaked it to be exactly what I want with a few exceptions. I found myself wanting the ability to lock the horizon ...
1 vote
337 views

### How do I use Transform.RotateAround to gradually rotate my GameObject around a new pivot in the shortest direction?

Given a normalized Vector2 or eulerAngles.z, I'm trying to gradually rotate a 2D box around a new pivot (the top of the box) ...
1 vote
999 views

### How do I increment a quaternion rotation in update()?

When working with rotations expressed as angles, it makes sense to be able do to something like void GameLoop::update(){ pawn.rotation.x += 0.01; } And slowly ...
• 359
92 views

### Yaw rotation not translating to Quaternion

I'm trying to implement the gimbal lock fix described in this question, but I end up getting weird behavior where when I rotate on the X axis (or try to at least) it rotates on both the X and Y axis ...
67 views

### How to rotate two transforms to touch at a point, while preserving forward direction?

I have a transform which I need to point one of its axes in the direction of another game object, without disturbing or rotating the other axes in any way. Consider the way your hips move around on a ...
• 58
1 vote
761 views

### How to make a concisely, elegantly, and human-friendly Quaternion camera?

I have spent three weeks struggling with the quaternion camera! Now I have two Implementations. One has some kind of gimbal lock issue or something like that. Another one is totally anti-human ( I ...
2k views

### Compute the difference between two quaternions and iterate with the difference

I would like to solve this with quaternions: A - B = C for(int i = 0; i < 10 ; i ++){ B += C/10 }; I want to get the difference (C) between two quaternions ...
• 43
1k views

### How does Unity's FromToRotation work? A major part of its behavior seems undocumented

All Unity's documentation states about what FromToRotation does is: Creates a rotation which rotates from fromDirection to toDirection. This seems to leave a ...
• 157
1 vote
1k views

### Calculate normal and plane orientation using 4 3D points

I have 4 points as Vector3 in 3D space that shape a plane. How can I calculate the plane normal direction these four points create together, and express it as a <...
• 41
1 vote
79 views

### Rotating a command relative to the body of a drone

Suppose you have a drone the shape of a cube with rotors on each face, it's completely unable to control its roll-pitch-yaw, but it can accelerate along any of its 3D orthogonal vectors (see image ...
• 11
116 views

### Rotate 'left' from the perspective of the space ship

I'm stuck on the following math problem for my game project. I have a space ship which position and orientation is saved in the following class: (The examples are in C# using types from the System....
• 10.2k
1 vote
2k views

### How to change quaternion when flipping X axis?

For a given animation with the set of 3D coordinates of every joint and corresponding global rotations quaternions Q(X, Y, Z, W) in right-hand coordinates (Y-up, X-...
1k views

### Get object rotation around the x axis

I have an object which can be rotated at 0, 90, 180, 270 degrees. I am using this to get the rotation data: transform.eulerAngles.x However that code keeps ...
1 vote
851 views

### How is the GLM '*' operator on quaternion and vec3 defined?

Using the definition of quaternion rotation given here: So the equivalent code in GLM of the above formula would be like this: ...
• 21
269 views

### Converting local rotation data from one rig onto another of a different orientation

I have an animated object which consists of a set of linked transforms. Think of them as bones. This object is animated - external to my software - and an API streams the local rotations - as ...
• 161
498 views

### How to rotate a sphere on its axis with a tilt?

How can I simulate a planet's rotation on the Z axis but tilted x° ( similar to how the Earth's rotation axis is tilted 23° relative to its orbit). I know with Euler angles I'll meet some gimbal lock ...
• 105
1 vote
958 views

### Applying incremental rotation with quaternions: flickering or hesitating

I'm having a couple of problems while rotating an object every frame with GLM. First problem I'm trying to rotate the object with a small increase using quaternion multiplication. ...
39 views

### How to find "roll" relative to horizontal

To avoid gimbal lock, I use quaternions for my rotations. For example, to roll I use this function: ...
• 103
264 views

### Is Quaternion math really practical knowledge for a graphics programmer?

I've recently had a graphics programmer interview and I was asked about math that is under the hood of quaternions. I briefly mentioned the formulas of using quaternions as rotations, but the ...
102 views

### writing a custom Quaternion.FromTo

I'm using the new Unity.Mathematics library. I'm trying to to replace Quaternion.FromTo(Vector3 from, Vector3 to) which returns a quaternion with what it would take ...
• 742
77 views

### Aircraft rotations in 3d game

It seems like rotating plane in 3d game on certain axis is not solution because they change based on current rotation. Also there is gimbal lock problem, so i guess i should use quaternions. Is there ...
• 103
422 views

### Issue with rotating character's spine bone in the late update

I want to make my character's spine rotate to look up and down. It's animated, so I have to rotate in the LateUpdate, not Update. The only I need to do is just simply rotate the chest bone through the ...
• 1,213
196 views

### Unity Follow Object Movement in Local Space?

I have two objects in my scene each at different positions and rotations in the scene. In this example, object A (the leader) moves according to controls. I need object B (follower) to follow the ...
282 views

### NVidia Physx get yaw pitch roll from rigid body orientation

I am using NVidia PhysX in the game that I'm developing and I stumbled upon a math problem. I need to retrieve Yaw, Pitch and Roll from the orientation quaternion stored in the rigid body of some ...
• 93
163 views

### How do you compute for angular spring physics for physics joints in game engines?

I'm working on fixing Godot's physics joints. Currently, it uses Euler angles and it doesn't help me in building active ragdolls for my game. I heard that using quaternions is the way to go. So I ...
• 51
79 views

### How to calculate accelation times and vector to orient a pointmass to a new orientation

I'm trying to design a space game where the user has 2 types of input: forward and backwards thrust in the current direction change orientation The game is based on actual physics, for the sake of ...
42 views

### Relationship between equal-magnitude quaternions with different components

What is the relationship called between two quaternions that are equal in magnitude, but different in component values? They are not necessarily unit quaternions.
1k views

### Smooth rotation to target with separate yaw, pitch and roll smooth times

I'm trying to write a camera script in Unity that would smoothly rotate the camera over time towards the desired rotation, with separate input parameters for yaw, pitch and roll smoothing, and I can't ...
449 views

### Quaternions and Euler Angles

I have made a simple animation in blender where the object(Bone in this case) is rotated from 0 to 360 degrees within 40 keyframes I then exported that data(Each keyframe) to glTF which stores the ...
• 119