Questions tagged [quaternions]

Unit quaternions are a mathematical representation of 3D rotations. They have 4 dimensions (one real and 3 imaginary) and can be represented as follows: a + i b + j c + k d or in terms of axis-angles: q = cos(a/2) + i ( x * sin(a/2)) + j (y * sin(a/2)) + k ( z * sin(a/2)) where: - a=angle of rotation. - x,y,z = vector representing axis of rotation.

A quaternion is a representation of a rotation from one coordinate frame to another coordinate frame. The mathematical relationship is given below:

If we have a quaternion:

q =  qw + i qx + j qy + k qz ;

The direction cosine matrix that represents the same rotation is given by:

   | 1 - 2*qy2 - 2*qz2   2*qx*qy - 2*qz*qw  2*qx*qz + 2*qy*qw |
   | 2*qx*qy + 2*qz*qw   1 - 2*qx2 - 2*qz2  2*qy*qz - 2*qx*qw |
   | 2*qx*qz - 2*qy*qw   2*qy*qz + 2*qx*qw  1 - 2*qx2 - 2*qy2 |

More information:

1469 questions
6
votes
1 answer

How to install IMUsim

This a guide rather than a question, because I spent a LOT of time fighting with compilation errors when installing IMUsim, and I know that many other researchers have struggled. The IMUsim code is currently unmaintained and the installation…
rleelr
  • 1,854
  • 17
  • 26
6
votes
3 answers

Interpolating rotations(slerp) using Eigen

I am trying to slerp between 2 quaternions using Eigen(thought would be the easiest). I found two different examples One, for(int i = 0; i < list.size(); i++) { Matrix3f m; Quaternion q1 = m.toRotationMatrix(); Quaternion
james456
  • 137
  • 1
  • 2
  • 9
6
votes
2 answers

How to rotate about the center of screen using quaternions in opengl?

I am trying implement arcball/trackball rotation but I have a problem with the center of rotation. I want the center to be the center of my screen no matter what. Let me explain what I have done so far. I've created a quaterion (rotation…
user228144
6
votes
2 answers

How to properly rotate a quaternion along all axis?

I want to code a first person camera with its rotation stored in a quaternion. Unfortunately there is something wrong with the rotation. The following function is responsible to rotate the camera. The parameters Mouse and Speed pass the mouse…
danijar
  • 32,406
  • 45
  • 166
  • 297
6
votes
3 answers

Is there a library for quaternions and matrices with all the standard operations?

is there a java library which can handle quaternions and matrices (quaternion matrix multiplication) with all the standard operations? (i searched google and here before - but didnt find any adequate solution)
manfred reichelt
  • 137
  • 1
  • 3
  • 9
6
votes
1 answer

Orient object's rotation to a spline point tangent in THREE.JS

I am using SplineCurve3 to plot a line only on the X and Y axis, I have a cube successfully animating along this line by using spline.getPoint(t) where t is 0-1 in time. I am trying to orient the cube to the line via its up vector which is Y using…
Neil
  • 7,861
  • 4
  • 53
  • 74
5
votes
2 answers

Why does my camera rotate around a point with this math?

My camera rotates around a point when I try to change the orientation. If I rotate my camera, say, 30 degrees in the Y axis, instead of the camera looking 30 degrees to the right, the camera rotates around the point it was looking at. o is the…
user1175938
  • 285
  • 1
  • 3
  • 6
5
votes
3 answers

Matrix multiply with position, quaternion and scale components

Part of my code stores the equivalent of a 4x3 matrix, by storing an xyz position, an xyz scale, and a quaternion. Code snippet below: class tTransform { // data tVector4f m_Position; tQuaternion m_Rotation; tVector4f …
Hybrid
  • 396
  • 4
  • 20
5
votes
1 answer

Rotating quaternions based on mouse movement (OpenGL and Java)

I'm writing a game in Java using OpenGL (the LWJGL binding, to be specific). Each entity, including the camera, has a quaternion that represents it's rotation. I've figured out how to apply the quaternion to the current OpenGL matrix and everything…
TranquilMarmot
  • 2,034
  • 2
  • 19
  • 25
5
votes
2 answers

LWJGL - Problems implementing 'roll' in a 6DOF Camera using quaternions and a translation matrix

I've spent a couple weeks on this issue and can't seem to find a proper solution and need some advice. I'm working on creating a Camera class using LWJGL/Java, and am using Quaternions to handle bearing (yaw), pitch and roll rotations. I'd like…
5
votes
1 answer

Quaternion rotation not working

I'm just starting to work with Quaternions, but I'm having some annoying difficulties getting a simple FPS camera to work properly using Quaternions. Basically, whenever I try to move the mouse, a triangle I draw on the screen goes crazy and moves…
Jarrett
  • 1,767
  • 25
  • 47
5
votes
2 answers

How to convert Euler angles to Quaternions and get the same Euler angles back from Quaternions?

I am rotating n 3D shape using Euler angles in the order of XYZ meaning that the object is first rotated along the X axis, then Y and then Z. I want to convert the Euler angle to Quaternion and then get the same Euler angles back from the Quaternion…
Amir
  • 10,600
  • 9
  • 48
  • 75
5
votes
0 answers

Can I use slerp multiple times to average quaternions?

As I understand slerp interpolates between two quaternions and returns an unit quaternion. So if I want to average 3 quaternions could I do(Assuming they all are close to each other): Eigen::Quaterniond t4; Eigen::Quaterniond u4; Eigen::Quaterniond…
Hakaishin
  • 2,550
  • 3
  • 27
  • 45
5
votes
1 answer

Madgwick AHRS algorithm Android implementation

I'm trying to implement Madgwick sensor fusion algorithm from here, to calculate orientation of my phone. It works relatively fine when I am moving, but it if the phone is steady on the table it starts to accumulate errors very quickly. I tried to…
5
votes
1 answer

How can I offset a global directional force to be applied over a local axis?

I want to apply a forward force in relation to the object's local axis, but the engine I'm using only allows to me apply a force over the global axis. I have access to the object's global rotation as a quaternion. I'm not familiar with using quats…
john doe
  • 547
  • 1
  • 6
  • 18