http://www.cprogramming.com/tutorial/3d/quaternions.html found a really great answer here. simple and concise....

c,matlab,vector,accelerometer,quaternions

You can apply a Kalman filter to accelerometer data, it's a powerful technique though and there are lots of ways to do it wrong. If your goal is to learn about the filter then go for it - the discussion here might be helpful. If you just want to smooth...

The most perfect answer has come to me after a lot of googling and experimentation: Disregard original ideas, acquire matrices! B.Matrix * Invert(A.Matrix) is stored as a relative marker, And then to restore, simply replace B's matrix with relative * A.MATRIX. This perfectly adjusts both rotation and position in one...

I did some tests on that equation and, to my surprise, it sometimes yields the correct answer and sometimes I get the correct answer multiplied by -1. Quaternion and quaternion multiplied by -1 represent exact same transformation (rotation). ...

vector,rotation,three.js,quaternions

another way to do this is to just make the cylinder LookAt(p2) if p2 is a vector.

You are looking for a quaternion q, such that qjq'=n, where n is the imaginary unit quaternion representing the axis of the object. This has a standard solution in terms of the product jn, essentially the square root. If jn=c+s*e, e imaginary unit, c²+s²=1, s>=0 then q = sqrt(0.5*(1+c)) +...

Find the difference quaternion qd = inverse(q1)*q2). Than find the angle between q1 and q2 by angle = 2 * atan2(qd.vec().length(), qd.w()) // NOTE: signed The "angle" here, is the angle of rotation from q1 to q2 by shortest arc....

See the answer to this question. I have a feeling what you are trying to implement is the Quaternion-Vector rotation operation. There are many different, obscure combinations of Quaternion conventions that can ruin your day (see this paper). if your rotation operation is not working try: V_inertial = q (x)...

Your matrix: matrix (a,b,c): a : 0.707107 0.000000 0.707107 b : 0.000000 -1.000000 0.000000 c : -0.707107 0.000000 0.707107 is orthogonal but it is not a rotation matrix. A rotation matrix has determinant 1; your matrix has determinant -1 and is thus an improper rotation. I think your code is...

c++,matrix,directx,quaternions,directxmath

You have two options. You can still use the XMQuaternionToAxisAngle() function, and it'll use an axis other than the cardinal axes. Any rotation can be represented as a single angle rotating around a given axis. On the other hand, if you really need to get it as Euler angles, there's...

rotation,quaternions,euler-angles,angle

Figured it out, and appreciate your help antont. It was a nuance of Assimp. Apparently it for some odd reason (bug?) reads rotations in backwards, and so you have to do ToEulerZYX, but then reverse use of xyz to zyx. float3 keyValueOrig = quat.ToEulerZYX(); float3 keyValue; keyValue.z = RadToDeg(keyValueOrig.x); keyValue.y...

There is an exact correspondence between 3x3 rotation matrices and unit quarternions, up to a sign change in the quarternion (the sign is irrelevant when in comes to performing rotation on 3D vectors). This means that given two quarternions, q1, q2, and their corresponding matrices, m1, m2, the action of...

ios,opengl,3d,rotation,quaternions

One way of looking at the top 3x3 portion of a matrix is that it's just a description of the basis vectors as, if you were to apply one to a point: [A D G] [x] [A*x + D*y + G*z] [A] [D] [G] [B E H] [y] = [B*x...

c++,eigen,quaternions,euler-angles

For Euler to quaternion see this page, and for quaternion to Euler angles, first copy it to a 3x3 matrix and then see the eulerAngles method.

c#,opengl,quaternions,rotational-matrices,sharpgl

At the end of the day, I want my object (Polygon in SharpGL terms) to rotate about its own axes (or about the "world" axes, but be consistent). I think this answer you put in your question is somehow explaining the situation. In order to perform rotation around object...

java,javafx,3d,quaternions,javafx-3d

There's a reason why all those tutorials point to rotational matrices: in 3D you can't perform simultaneous rotations one by one, you need to perform them at once. Since JavaFX only uses one angle and one axis, you have to provide the way to convert three rotations over three axes...

javascript,html,keyevent,quaternions

Use onkeydown or onkeypress or onkeyup instead of onkeyclick.

unity3d,rotation,quaternions,clamp

The problem seems to be in your if state logic. Lets break it up in some logical blocks: If the value is bigger then 65 > check the next block If this is not the case that means the value is under or equal to 65 and the if wont...

opengl,camera,rotation,three.js,quaternions

You want the rotation from the point of view of the rotated object so you need to left-multiply the rotation. So if the final MVP matrix is from perspective*view*model then you need to insert the rotation between the model and view matrices. function rotateAroundObjectAxis(object, axis, radians) { var rotObjectMatrix =...

javascript,unity3d,camera,quaternions,euler-angles

The issue I discovered was with using: _target.localEulerAngles.y as a base. This is because localEulerAngels only go from 0 to 360 while running. In the editor, it isn't clamped. When running, it is clamped. This changes things dramatically because initially at rotation 0, if you move left, it loops to...

From what I understood of your question you have two particles P1 and P2 that have a rigid transformation between them (at all times the relative position and relative orientation between P1 and P2 are constant). The answer is similar to this answer however it is a bit different. Lets...

Instead of using a chain of glRotate calls, retrieve a 4×4 matrix from the quaternion instance using MatrixToQuaternion and multiply that onto the matrix on top of the stack with glMultMatrix. In a further step you should get rid of using any code using the OpenGL fixed function matrix stack...

actionscript-3,math,quaternions,away3d

Changing the order worked q.multiply(qu, q );...

c#,rotation,unity3d,reverse,quaternions

You can use the Quaternion.Inverse() function. This gives back the opposite rotation. So it should reverse. You can use it this way: transform.rotation = Quaternion.Inverse(target.rotation); Source: http://docs.unity3d.com/Documentation/ScriptReference/Quaternion.Inverse.html...

Just found answer in one wiki article: var angle = Math.PI/2; var axis = [0,0,1]; var w = Math.cos(.5 * angle); var x = axis[0] * Math.sin(.5 * angle); var y = axis[1] * Math.sin(.5 * angle); var z = axis[2] * Math.sin(.5 * angle); var quaternion = new Quaternion(w,...

math,rotation,quaternions,rotational-matrices,numerical-stability

That Wikipedia article is biased. From http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Advantages_of_quaternions as of Apr 18, 2014: When composing several rotations on a computer, rounding errors necessarily accumulate. A quaternion that’s slightly off still represents a rotation after being normalised: a matrix that’s slightly off may not be orthogonal anymore and is harder to convert...

If I understand you correctly, you have two objects that have a rigid transformation between them. The problem is that you want to calculate the pose (position + orientation) of one, given the pose of the other. Let's say you have three frames; the Station frame "S", the Vehicle frame...

c++,rotation,vector-graphics,quaternions

I ended up deciding to just incorporate GLM into my math classes and after some changing of things, everything works as it should.

c++,opengl,vector,transformation,quaternions

Apparently I still had some leftover old code applying manual orientation changes to all children of a parent, outside of the shader, as suggested by @ratchet freak I thought it was just a coincidence resulting from bad math, but it turned out to actually be a full double rotation of...

unity3d,rotation,movement,quaternions,oculus

Good news! For your purposes you won't need to deal directly with quaternions. A little vector math might help, though. transform.forward in any script will give you the forward direction of the object the script is attached to. If it's on the camera, it will be the direction the player...

java,math,geometry,quaternions

The answer can be found here Component of a quaternion rotation around an axis "swing twist decomposition" from http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition/...

matrix,interpolation,quaternions

I ended up solving my question through a bit more web surfing. For future reference, heres how to do it. The transformation component is stored in a 4x4 matrix like this: r r r t r r r t r r r t 0 0 0 1 where r is...

math,matrix,3d,quaternions,rotational-matrices

vec_res = (inverse(VM) * conversion_to_matrix(q) * VM) * vec_input Is perfectly valid. The problem is... inverse(VM) * conversion_to_matrix(q) * VM is NOT equal to conversion_to_matrix(q) Therefore you have to keep the original equation in its entirety....

javascript,math,quaternions,gl-matrix

I interpret it the way that the unit vector of the Z axis (in local coordinates) is your forward pointing vector? The quaternion a describes the translation of the local coordinate frame to the global coordinate frame. Thus a vector v in local coordinates has direction a*v*a' (a'=conjugate of a=inverse...

ios,quaternions,core-motion,scenekit

What you're looking for is a low pass filter — a way to separate the high frequency signals in a sensor input (noise, random jiggling) from the low frequency ones (deliberate user motion). The typical formula for a real-time filter goes like this: newValue = (sampledValue * factor) + (lastValue...

ios,rotation,quaternions,scenekit

after a long testing session and observation I could find out that there is no gimbal lock. and my edited calculation is correct: if(myPitch >= pitch + 1 || myPitch <= pitch - 1) { int angle = myPitch > pitch ? 5: -5; // left or right tilt GLKVector3...

so you want to find rx where rx * r0 == r1? rx * r0 * conj(r0) == r1 * conj(r0) rx == r1 * conj(r0) All you need to know is that a rotation around q = q2 * q1 is equivalent to a rotation first around q1 and...

java,processing,matrix-multiplication,quaternions,oculus

If you're working with the Oculus SDK Matrix4 class, you can easily use the Matrix4::ToEulerAngles() method. If you're working with another class then you should look for a method in that class that does something similar.

The problem was that i didnt save the result of Matrix Transform point3D = matrix.Transform(point3D); // now point3D rotates as it should be ...

Stack Overflow isnt a code writing service but i will explain what you must do: Method 1 (Exact Aiming): For every frame the mouse is down: Make a Ray from a screen point... hint (use camera.ScreenPointToRay). Get a far point along the Ray using ray.GetPoint(distance);. Bow.Transform.LookAt(newPoint, Vector3.Up);. Method 2 (Continuous...

c++,opengl,rotation,geometry,quaternions

Your code is using Euler angles (axis-aligned rotations). The wiggles and jumps are because Euler angles are a bad parameterization of the space of 3D rotations. Instead, here are two alternate approaches. Constructing a Rotation Matrix via a Frame Assuming the bird is pointing down the x-axis and up in...

opengl,math,rotation,transformation,quaternions

I was indeed normalizing vectors without checking them, adding a tolerance threshold resolved my problem. Thanks everyone for the help....

For update of orientation , you require to multiply current orientation by delta rotation. This is comparable expensive operation with axis angle conversion. Common way to represent angular velocity is "exponential map"m the 3d vector parallel with rotation axis and magnitude of rotation velocity (radians per second). The conversion to...

rotation,directx-11,matrix-multiplication,quaternions

Your code XMVECTOR quaternion = XMVectorSet(random_x, random_y, 0); is not creating a valid quaternion. First, if you did not set the w component to 1, then the 4-vector quaternion doesn't actually represent a 3D rotation. Second, a quaternion's vector components are not Euler angles. You want to use XMQuaternionRotationRollPitchYaw which...

c++,vector,rotation,quaternions

I think it's possible to do what you want very quickly and efficiently. First thing, you should complete each orthonormal pair of vectors into an orthonormal basis. The obvious way to do so is by taking the cross product of the first two vectors. Order matters: if you want u0...

linear-algebra,quaternions,ros,inverse-kinematics

Isn't this just as simple as exchanging the order of the factors in the quaternion product? A unit quaternion q transforms a vector v in local coordinates to the rotated vector q*v*q' in global coordinates. A modified quaternion a*q*b (a, b also unit quaternions) transforms v as a*(q*(b*v*b')*q')*a', where the...

c++,geometry,quaternions,euler-angles

The quaternions -q and q are different; however, the rotations represented by the two quaternions are identical. This phenomenon is usually described by saying quaternions provide a double cover of the rotation group SO(3). The algebra to see this is very simple: given a vector represented by quaternion p, and...

camera,rotation,quaternions,sharpdx

Kryzon from the BlitzBasic.com forum helped me out here (s. his post at http://blitzbasic.com/Community/post.php?topic=102458&post=1224801): internal static class QuaternionExtensions { internal static Vector3 GetYawPitchRollVector(this Quaternion q) { return new Vector3(q.GetYaw(), q.GetPitch(), q.GetRoll()); } private static float GetYaw(this Quaternion q) { float x2 = q.X * q.X; float y2 = q.Y *...

java,3d,rotation,quaternions,jmonkeyengine

You have stated that in your case startOrientation was being modified. However; the following remains true Interpolating between quaternions The method slerp is included within the Quaternion class for this purpose: interpolating between two rotations. Assuming we have two quaternions startOrientation and endOrientation and we want the point interpolation between...

ios,rotation,quaternions,core-motion,scenekit

To track a resting orientation, you'll need to keep track of the first CMAttitude you sample. Then you can use multiplyByInverseOfAttitude: to get the difference between that attitude and the current one each time you sample. (If you're already working with quaternions due to filtering, you can perform the equivalent...

opengl,graphics,3d,directx,quaternions

The problem is the way that you are accumulating rotations. This would be the same whether you use quaternions or matrices. Combining a rotation representing pitch and yaw with another will introduce roll. By far the easiest way to implement an FPS camera is to simply accumulate changes to the...

The error is in the usage of Quaternion.LookRotation. The function takes two Vector3 as input which are a forward direction in world space (and an optional up vector - default Vector3.up), and returns a Quaternion representing the orientation of such a reference frame. You are instead supply a world space...