# Tagged Questions

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.

31 views

### Rotate character 180 degrees determine direction

In my game it should be possible to rotate the character 180 degrees. I always want the character to rotate clockwise. If the character is rotated 0 degrees and I press the rotate button, the ...
29 views

### Limit/Clamp camera movement using quaternions

I'm making a camera object for rendering with OpenGL. However, instead of using the typical "LookAt" method I'm trying to use just a Quaternion for orientation and a Vector3 for position. Instead of ...
60 views

### Quaternion based camera pitch freaking out, and Z-axis drift

This is the code I use to control my (first person) camera's movement and rotation. Translation successfully keeps orientation in mind, so that up and left and such are always in the expected ...
84 views

### Unwanted roll when rotating camera with pitch and yaw

I have a quaternion class implementation, and when I apply this class to my objects all gone right (rotations), but I have a lot of troubles with the camera. I've been searching a lot trying to solved ...
26 views

### Rotate camera with quaternions

I have a camera with a 3D vector, the position, and a quaternion, the orientation. I'm able to move the camera in a realistic way (respect the local axis) but I can't do the same with the rotation. ...
103 views

### How can I min-max quaternions?

What I'm doing In my engine, I'm trying to implement a camera that will follow a target object, such as a player. I wanted to avoid just simply using the inverse of the target's transformation, ...
76 views

### Problem with Quaternions and Unity's Euler Angle Convention

So I want to rotate an UI-Element according to my magneticHeading, I just want to apply the magnetic heading to the z rotation in EulerAngles. So I tried to do so, which brought me to some weird ...
42 views

### Rotation of a point around axis using quaternions

I have a simple processing program to rotate a point around arbitrary axis but it stops after a bit. I'm trying to get full rotation of the point around the axis. import org.apache.commons.math3....
48 views

I'm working with quaternions and matrices 4x4 and 3x3, and I have a doubt. I think that adding and multiplying quaternions is the same that converting the quaternion to a matrix, do the operation and ...
17 views

### Set up a basic D3DXQUATERNION

I'm trying to set up a D3DXQUATERNION to operate a rotation of 90 degrees around the Y axis. I tried in the following way: D3DXQUATERNION tempRot1(0.0f, 1.0f, 0.0f, cos(XM_PIDIV2/2)); because in ...
46 views

### Quaternion not giving correct value back. What am I doing wrong here?

Right so I made a quaternion and assigned it a value but it reports back the wrong value. Here is the relevant code... Quaternion LeftTurnLimit = Quaternion.identity; float test = 0.1f; ...
34 views

### Camera movement on a sphere, and how to look while doing it

I am trying to make some kind of pointerlocked walking simulator that involves movement of the camera on the inside of a sphere. I've looked at Walking on a sphere, but that solution fights what I'm ...
96 views

### Why does transforming a Vector3 by a Quaternion result in reversed Z?

I'm trying to transform the vector (1, 0, 0) by an orientation unit quaternion, which in XNA should be: Vector3 v = Vector3.Transform(Vector3.Right, Orientation); But this results in the Z value ...
45 views

### Rotate smoothly object to angle (Y axis) of the collided object

Well, let's say I have two planes, one which I am moving, and another one that I collide with, that has a different y rotation. I want to make that, once both planes collide, the plane the user ...
33 views

### Limit Quaternion/vector3 axe in a certain interval

I have some trouble to understand, and handle Quaternion and Vector3. I'm improving the tutorial Tank of Unity: EDIT: Because a video explain so much better, there is a link to the 30 secondes video ...
34 views

### How to rotate with quaternions

I need to simply rotate around an axis, but because unity uses quaternions for calculating i have issues with converting into euler angles. When i ask for rotation of an object in euler angles it ...
52 views

### How to get correct quaternion value from real world to screen?

I'm writing an application (not a game per se, but close enough) where we use attitude sensors (an IMU) in the real world to affect the orientation of an object in the application's 3D space (OpenGL). ...
136 views

### Unity Change Ball Direction after hitting paddle in a Pong game (like in dx-ball)

I'm struggling with how to get the ball to change the bounce based on where it hits on the paddle. Normally in a pong game, the angle changes, depending on how far from center the ball bounces, and ...
132 views

### 360 degree quaternion interpolation?

I am in the process of implementing interpolation into a simple game loop I am playing with after reading the infamous "fix your timestep" article (which is amazing by the way). I have the position ...
149 views

### Rotation around arbitrary vector (using quaternions?)

I currently have a camera which orbits a specific target object, always looking at it. The user can drag the mouse to move the camera left/right/up/down and the camera will move over the surface of a ...
63 views

### Rotate object with mouse look script

I would like to rotate an FPS camera slightly upwards during a shot as an effect of recoil, but the problem is that I have a mouse look script as well and I assume it prevents me from achieving the ...
149 views

### Unexpected quaternion rotation behavior

First off let me apologize for the vague title but I really couldn't think of a more descriptive one (maybe after reading this a more advanced user might be able to edit it). Alright, so I have been ...
104 views

### How to programmatically create an animation that linearly interpolate between two rotations?

I would like to programmatically create an animation that linearly interpolate between two angles (using the shortest path). I wrote the following code : Animation anim = gameObject.GetComponent<...
106 views

### Moving a ship forward from rotation

I am making a simple space simulator, where the player can control a ship using 2 controls, one for pitch and one for bank. The ship is properly rotated but I cannot figure out how to make the ship ...
59 views

### Increasing the rotation angle on a quaternion makes the rotation stop at a certain angle

I'm using the following code to change the rotation of an object: Quaternion rot = getRotation(); setRotation(make_quaternion_axis_angle(rot.v,rotationSpeed*dt)*rot) This code works as expected ...
159 views

### How to avoid Gimbal Lock on Rubik's Cube [duplicate]

I am making a Rubik's cube program. That will simulate a Rubik's cube. I am having problems with gimbal lock. I need to know how to avoid it. To my understanding I can either multiply the x, y, z ...
48 views

### Quaternion Types in Game Engine

I've recently been coding a quaternion class for my game engine and have run into a problem. Firstly, should I be using unit quaternions for my engine? Secondly, should I have the functions ...
32 views

### align local Y to be parallel with global Y during or after slerp

I am using the following function to have a globe rotate a point on its surface to face the global Z toward the camera. This works fine, but after each rotation the Y axis seen as a green line is not ...
57 views

### Rotating object around a rotating one?

I am developing a solar system animation in Unity3D. Planets rotates around sun. But ı have an issue simulating satellites like Moon. Moon should be rotating around world normally and moon should be ...
122 views

### Rotate camera with quaternion around axis going through the origin

I am trying to implement my own third person camera using quaternions in DirectX. I first wanted to check that the camera rotates as expected so I started to rotate it around the world y-axis (0,1,0) ...
148 views

### Quaternion rotation problems [duplicate]

I want to rotate my model and I have X and Y rotations. Here is my code: D3DXQUATERNION q, qrotation; D3DXQuaternionRotationAxis(&q, &D3DXVECTOR3(1.0f, 0.0f, 0.0f), m_matrixRotX*0....
170 views

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

Software: Unity v5.2.1f1 Personal I am trying to achieve the effect of a turret in Unity. For this I have a turret consisting of 3 parts as well as a target. The problem is that whenever the target ...
107 views

### Euler adjustments between two quaternions

I have two quaternions, q1 and q2. If my object's current rotation is at q1, but I need to get it to q2, what would be the process to figure out how much rotation I apply to x, y, and z in order to ...
100 views

### Applying angular velocity to quaternion

I am reading Game Physics Engine Development by Ian Millington currently. In his book, he represent an orientation of rigid body by quaternion. I don't understand the formula where he apply angular ...
40 views

### How do you use the distributive law with Quaternions and vectors?

I'm trying to solve for the distance from Obj1 to Obj2 relative to Obj1, because I do not know their global positions, rotations, or the difference between their local spaces. Thankfully, they are ...
116 views

### Translation & Rotation Transform Hierarchy

I've struggled to find a hierarchical transform class in C++ that is similar to that of Unity's (without scaling) that uses quaternions as opposed to matrices. So I figured creating my own wouldn't be ...
206 views

### Quaternion.LookRotation() not rotating 360 degrees

In my scene I have two cubes one has a tag "Respawn" and another one has the following script attached: ` using UnityEngine; using System.Collections; public class NewBehaviourScript : ...
80 views

### How much to roll Z to make horizon level

I've got a flying camera with some arbitrary rotation. (It also has a translation, but that's not important.) It's flying along its local Z axis, traveling in some direction over the ground with some ...
129 views

### 3D 3-axes rotation into 3D 2-axes rotation

Hello everyone and thanks in advance to anyone who'll help me through this ! I am currently working on the Kinect V2 (for XBox One) to interact with an avatar. I'd like to use the rotation quaternion ...
189 views

### Quaternion rotations & transforms from global to local space

I am trying to solve this problem and getting no where, could really use some assistance. Rotation is defined as X (rotate left/right), Y(rotate up/down), Z(roll) Coordinates are X: Forward/backward, ...
155 views

### Quaternion.Lerp not working properly in Unity3d

I'm using Quaternion.Lerp to rotate a joint with a certain angle, but when I use the below code I find the joint rotating very far although I specified it to rotate with only 5. Any thoughts please? ...
170 views

### Unity 3D - Rotate towards object with random offsets

Title is a little confusing, but let me explain: I want to make the enemies look at the player, and shoot at him, with random precision, meaning that one time the enemy will shoot a little bit to the ...
125 views

### Rotation in 3D space using Quaternion

System Configuration I have two simulation systems (which I am going to call Sim-A and Sim-B) where I am going to spawn an entity created in Sim-A inside Sim-B. Expected outcome The entity created ...
49 views

### Interpolate camera rotation over many keyframes smoothly

I have a defined set of rotation/position keyframes that I want a camera to animate between smoothly. Handling the position is easy enough using cubic bezier curves (and just auto-generating the ...
200 views

### Does converting quaternion to matrix cause a lot of overhead?

This is related to rendering creating a model, view, projection matrix for opengl. While matrix are fairly standard there's a lot of talk about using quaternions for rotations but why would u go from ...
120 views

### How to calculate a quaternion rotation between 2 vectors with a specific final up vector?

I know you can calculate the quaternion rotation between 2 vectors with something like this after all the optimizations: quat quat::fromtwovectors(vec3 u, vec3 v) { vec3 w = cross(u, v); ...
606 views

### Rotate model to face direction it's traveling in 3d with scenekit and swift - Boids implementation

I am implementing a boids simulation using Swift and Scenekit. Implementing the simulation itself has been fairly straight forward however I have been unable to make my models faces the direction they ...
48 views

### Quaternion camera in 3D space with Pitch and Yaw

I am having trouble implementing a quaternion camera that can fly freely in 3D space with only Pitch and Yaw rotations. It works fine except when you look up or down and then try to look left or ...