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
-1
votes
1 answer

What is a quaternion? And how is it used in graphics?

I've seen other stackoverflow answers such as What's a quaternion rotation? but I'm still not sure what they are When I looked it up on Wikipedia, it gave me a 4-dimensional imaginary coordinate space. Can anyone explain to me what they are in the…
JayC
  • 159
  • 1
  • 3
  • 14
-1
votes
1 answer

C# programming logic (Unity3d script)

I have a script for player to open and close the door but when I press the button to close the door, it goes closes and then goes open again. I suspect it is because the lerp doesn't stop or something. How can I fix this? What's wrong? Thanks! Door…
Mingan Beyleveld
  • 281
  • 2
  • 5
  • 19
-2
votes
1 answer

Rotating Quaternions

This is code for a turret who shoots lasers at a player, a capsule. The lasers currently come out in a wrong rotation, it's upright rather than how a laser usually looks. My code works perfectly so far, no bugs. How do I fix this? void…
CodingTigers
  • 13
  • 1
  • 5
-2
votes
2 answers

Unity camera follows player rotation

I want my camera to follow the player rotation but the camera should always have an angle to the player. I have this: transform.rotation = player.transform.rotation; But now the Camera looks straight at the player and not at an angle from above.…
-2
votes
1 answer

How to recalculate a 3d normal when the model is scaled?

I have a 3d model and I want to recalculate the normal when the model is scaled (non uniformly). For example, I have a 3d model and when i scale non uniformly, the normal should be affected 1) Figure 1, the model is not scaled. 2) Figure 2, the…
magallanes
  • 6,583
  • 4
  • 54
  • 55
-2
votes
1 answer

correct way to make quaternion from local Euler angles

I am trying to lerp from rotation one to another. The another rotation is constitute using this Quaternion qNew = Quaternion.Euler(new Vector3(navigationCanvas.transform.rotation.x, navigationCanvas.transform.rotation.y,…
Muhammad Faizan Khan
  • 10,013
  • 18
  • 97
  • 186
-2
votes
1 answer

Quaternion to euler angles and euler angles to quaternion in C

I have been writing this code for checking the euler angles and quaternions, but it is not run correcly (or maybe I do not understand the rotations): #include #include #define DR2D (180 / M_PI) #define DD2R (M_PI / 180) int…
tres.14159
  • 850
  • 1
  • 16
  • 26
-2
votes
1 answer

Eigen passing Quaternionf, discards qualifiers

i am trying to use Eigen::Quaternionf. But i am getting when i just want to asign one Quaternion an error. oldQuat = pos; both are Eigen::Quaternionf, the following error is given. Is must be because the Methods are declared as constant (see:…
Lenny
  • 111
  • 1
  • 3
  • 13
-2
votes
1 answer

Redefining the syntax in Racket to accept quaternions

Is there a way to redefine the syntax in the top level of Racket to accept quaternions so it will evaluate it as a datum similar to complex numbers? I am trying to get 1+i+j+k to be accepted by the REPL. Any code examples or relevant documentation…
-3
votes
1 answer

How to implement camera rotation like UE4 using quaternions?

I tried many times, but I can't get the result what I want. my rotation logic is like this. if mouse move to left or right, then rotate yaw. if mouse moves to up or down, rotate pitch. Mouse can moves to diagonal direction. so in this case I will…
woohyeon
  • 29
  • 6
-3
votes
1 answer

how to map vectors and quaternions to the specific gameObjects?

The target is to get gameobjects names and vectors, quaternions axis from an XML file and map axis to gameObjects names. The exact problem is: mapping GameObjects to its axis and assigning a value to this axis to move mapped GameObjects according…
Hu Man
  • 71
  • 1
  • 1
  • 7
-4
votes
1 answer

Who has EKF filter open source code?

I have been working on IMU sensors to get orientation and I am looking for an open source EKF filter! Or please share ur expertise if anyone has experience!
Bobur Kobulov
  • 361
  • 4
  • 5
-5
votes
2 answers

THREE JS / Animate rotation of a mesh on its Y-axis to face direction

I'm trying to make StarCraft like game in THREE.JS.. I have problem with rotating object on its' Y-axis to face the new direction, and then change position. and by rotating I mean ANIMATING / so please stop with a crappy lookAt() function I would…
-6
votes
1 answer

Using Scenekit, how can I get an identity quaternion?

Ah, go on then. I'd like to create a SCNTransformConstraint orientation constraint so that a SCNNode is always oriented to the world's x, y & z axes, no matter how the node's parents are oriented / move about. I can create an orientation constraint…
Benjohn
  • 13,228
  • 9
  • 65
  • 127
1 2 3
97
98