FAQ Database Discussion Community


Is there a way to convert a quaternion to angles?

c++,matrix,directx,quaternions,directxmath
I have a (world) matrix, and it applies translation, rotation and scale into an 3D object. It is created with the function XMMatrixTransformation (DirectXMath) and the parameter RotationQuaternion is made by a call to XMQuaternionRotationRollPitchYaw. Then it is stored in a file along with other data. Then I need to...

rotation matrix to quaternion (and back) what is wrong?

c++,quaternions,jmonkeyengine
I copied a code for conversion of 3D roation matrix to quaternions and back. The same code is used in jMonkey (I just rewrote it into my C++ class). However, it does not work properly (at least not as I would expect.) e.g. I made this test: matrix (a,b,c): a...

Custom C++ Quaternion Rotation Not Working Correctly

c++,rotation,vector-graphics,quaternions
In my code, I have a quaternion that is used for rotation for a camera for the player. Rotation itself seems to work fine, but my directional vectors for moving and to rotate on do not rotate correctly. Quaternion Multiplication: Quaternion Quaternion::operator*(Vector3 other) const { float x_ = w *...

Keep a relative position using quaternion orientation

math,quaternions
Let's say I have an object (A) with a position stored as a 3-number vector, and an orientation stored as a quaternion. I have a second object (B) with the same information. Object B is, for whatever reason, suddenly welded to object A. It is now stuck, and should perfectly...

Rotate Point3D around Unit Vector, Solved

c#,wpf,rotation,quaternions
as an Image above i want to rotate the point P1 around unit vector RotationAxis (Red vector in Image and its in Center). in my program (WPF) i Have a Quaternion and a 3DPoint. How can i rotate the Point P1? i tried Matrix rotation but it rotates nothing. Matrix3D...

Rotate a 3D object on 3 axis in JavaFX properly

java,javafx,3d,quaternions,javafx-3d
So the method that I've used so far to rotate objects in JavaFX was that I layered it in 3 groups, each of them with a Rotate attached and locked to a single axis like so: Rotate heading, roll, pitch; Group normalrotate, rollrotate, verticalrotate; heading.setAxis(new Point3D(0,1,0)); normalrotate.getTransforms().add(heading); roll.setAxis(new Point3D(0,0,1)); rollrotate.getTransforms().add(roll);...

Calculating rotation delta between two quaternions (as another quaterion)

math,quaternions
I have some initial rotation r0 represented by quaternion and some actual rotation r (also an quaternion). I would like to get the quaternion that represents the delta of rotation. E.g. if r0 stands for 30st OX rotation and r is 50st OX, the rDelta should contain quaternion that represents...

Orienting an object based on a parent with quaternions?

c++,quaternions
I have 2 objects in 3D space, A & B, and object B is parented to A. Both objects have 3D positions, as well as a Quaternion representing their specific orientations. I have translation working fine, so whenever A moves, B moves. However, I can't seem to get the orientation...

Quaternion to EulerXYZ, how to differentiate the negative and positive quaternion

c++,geometry,quaternions,euler-angles
I've been trying to figure out the difference between these, and why ToEulerXYZ does not get the right rotation. Using MathGeoLib: axisX: x 0.80878228 float y -0.58810818 float z 0.00000000 float axisY: x 0.58811820 float y 0.80877501 float z 0.00000000 float axisZ: x 0.00000000 float y 0.00000000 float z 1.0000000...

Fast Quaternion-Vector Multiplication with other Transformation Matrices

math,matrix,3d,quaternions,rotational-matrices
I am currently trying to find an equivalent for the following equation: vec_res = inverse(VM) * (q * (VM * vec_input) * conjugate(q)) where VM is a standard view matrix , q is a normalized quaternion, and vec_input a vector. In the form: vec_res = A * vec_input; or vec_res...

Quaternion based camera

opengl,graphics,3d,directx,quaternions
I try to implement an FPS camera based on quaternion math. I store a rotation quaternion variable called _quat and multiply it by another quaternion when needed. Here's some code: void Camera::SetOrientation(float rightAngle, float upAngle)//in degrees { glm::quat q = glm::angleAxis(glm::radians(-upAngle), glm::vec3(1,0,0)); q*= glm::angleAxis(glm::radians(rightAngle), glm::vec3(0,1,0)); _quat = q; } void...

Quaternion Rotation Between Two Sets of Vectors

c++,vector,rotation,quaternions
I would like some help on finding the rotation between two sets of two vectors in 3D as a quaternion. In each pair, the vectors would be at right angles to each other and have unit length (basically two vectors in an orthonormal basis). My current code looks something like...

Quaternion product is different from the quaternion extracted from the matrix product

three.js,quaternions
Yesterday I have been trying to solve the following problem: calculate the local rotation quaternion for a bone given its global rotation quaternion and the skeleton state. I figured that the global quaternion equals to the parent bone global multiplied by the bone's local quaternion: global = globalParent * local...

Applying a “Spread” value to an XMFLOAT4X4

rotation,directx-11,matrix-multiplication,quaternions
I'm attempting to add a small value to a World Matrix in order to replicate the accuracy of a fired weapon [pistol, assault rifle] Currently, my World Matrix resides at a Parent Objects' position, with the ability to rotate about the Y axis exclusively. I've done this in Unity3D, running...

How to synchronize the position of two points with the same orientation represented in quaternion?

translate,quaternions
I have two points with fixed distance (e.g. 30 centimeter) and exactly the same orientation in 3D space. The position of point 1 (x1,y1,z1) and orientation of point 1 (represented in quaternion q0, q1, q2, q3) are already known. How can I calculate the position of point 2 ? (No...

Difference Between Combining Quaternion Rotations and Rotation Matrices

matrix,rotation,quaternions
Is the result of combining two quaternion rotations the same as that of two matrices and then converting that into a quaternion? I have a quaternion (q1) and rotation matrix (m2) as input for a function (unfortunately non-negotiable) and would like to rotate the initial quaternion by the matrix resulting...

Transformation Hierarchy - applying a parent's orientation to its children

c++,opengl,vector,transformation,quaternions
My goal: When being rendered, a child object needs to render relative to its parent; thus its own position and orientation need to be relative to its parent My problem: Translations work, but the parent's rotation/orientation isn't correctly being added to a child's transformation calculation; the child rotates on its...

How to rotate objects in OpenGL relative to local or global axes

c#,opengl,quaternions,rotational-matrices,sharpgl
I'm asking a question that has been asked a million times before, but I still haven't found a good answer after going through these and also resorting to other sites: How to rotate a graphic over global axes, and not to local axes? rotating objects in opengl How to rotate...

Add 90 degrees to a Quaternion in Away3d

actionscript-3,math,quaternions,away3d
I'm attempting to rotate a Quaternion up 90 degrees on the Y axis in Away3d. I'm using an ANE to get Quaternion values from device motion, to set the camera view. This rotates the angle up, qu.fromAxisAngle(Vector3D.X_AXIS,Math.PI/2); q.multiply(q, qu ); But then seems to switch the other angles, i.e. now...

Kalman filter - quaternions - angle sensor

c,matlab,vector,accelerometer,quaternions
Kalman filters and quaternions are something new for me. I have a sensor which output voltage on its pins changes in function of its inclination on x,y and/or z-axis, i.e. an angle sensor. My questions: Is it possible to apply a Kalman filter to smooth the results and avoid any...