quaternions

Faster quaternion vector multiplication doesn't work

两盒软妹~` 提交于 2019-12-05 02:23:45
问题 I need a faster quaternion-vector multiplication routine for my math library. Right now I'm using the canonical v' = qv(q^-1) , which produces the same result as multiplying the vector by a matrix made from the quaternion, so I'm confident in it's correctness. So far I've implemented 3 alternative "faster" methods: #1, I have no idea where I got this one from: v' = (q.xyz * 2 * dot(q.xyz, v)) + (v * (q.w*q.w - dot(q.xyz, q.zyx))) + (cross(q.xyz, v) * q.w * w) Implemented as: vec3 rotateVector

What's a quaternion rotation?

那年仲夏 提交于 2019-12-04 22:35:45
Is quaternion rotation just a vector with X,Y,Z which the object will rotate towards, and a roll which turns the object on its axis? Is it that simple? Meaning if you have X=0, Z=0 and Y=1 the object will face upwards? And if you have Y=0, Z=0 and X=1 the object will face to the right? (assuming X right, Y up and Z depth) A quaternion has 4 components, which can be related to an angle θ and an axis vector n . The rotation will make the object rotate about the axis n by an angle θ. For example, if we have an cube like ______ |\ 6 \ | \_____\ z |5 | | : y ^ \ | 4 | \| \|____| +--> x Then a

Find final world coordinates from model matrix or quaternion

巧了我就是萌 提交于 2019-12-04 21:10:03
I am displaying an object in OpenGL using a model matrix for the object, which I build from my pre-stored object location AND a quaternion applied to the rotation. I need to find the final cartesian coordinates in 3D of my object AFTER the rotations and transformations applied (the coordinates that the object appears at on the screen). How can I get the plain coordinates? If I understand correctly, you have an object; if you rendered it without applying any transformation, its center would be at [0,0,0] . You have a point, [a,b,c] , in 3D space. You apply a translation to the modelview matrix.

Controling OpenSceneGraph camera with Cartesian coordinates and Euler angles

谁都会走 提交于 2019-12-04 19:36:04
I am attempting to control an osg::Camera with Cartesian coordinates (X, Y, Z) and Euler angles (Yaw, Pitch, Roll) that I read in from file. Part 1 For some reason setting my roll will cause the camera to rotate around the z-axis and not the y-axis as expected. The following is the previously written camera manipulator that I am feeding my positional data to. class EulerManipulator : public osgGA::CameraManipulator { public: EulerManipulator(osg::ref_ptr<osg::View> x) : view(x), camView(new osg::CameraView) { } virtual ~EulerManipulator(){} virtual osg::Matrixd getMatrix() const { // Note: (x,

Arcball Rotation at 90 degrees

社会主义新天地 提交于 2019-12-04 16:51:33
I have successfully implemented Arcball rotation through quaternions, but am confused at what to do when the direction vector of the camera is parallel to up vector. Currently I am just restricting the rotation along the x-axis (the pitch) when the dot product of the direction vector and the up vector exceeds 0.99. In Maya (or Max, XSI where arcball rotation is used) for example, you can rotate around in a full circle very smoothly. I am hoping for a solution similar to that of Maya's rotation. Thankyou You need to adjust both the view normal vector (VNV) and the view up vector (VUV) and

Quaternion from Tait-Bryan angles

核能气质少年 提交于 2019-12-04 13:29:46
I am writing a camera with SharpDX and rotate it with the help of a quaternion. The camera rotation is set with pitch (X rotation), yaw (Y rotation) and roll (Z rotation), so called "Tiat-Bryan" angles (these are not Euler angles which would have an XYX rotation, and not XYZ). I am using a left-handed coordinate system: X+ is rightwards, Y+ is upwards, Z+ is downwards the screen. If I rotate around X ("pitching"), positive values make the camera look downwards. If I rotate around Y ("yawing"), positive values make the camera look leftwards. If I rotate around Z ("rolling"), the camera rolls

Why won't my Quaternion rotate properly?

≡放荡痞女 提交于 2019-12-04 13:06:11
Ok, we are not talking about OpenGL with this question, but this will be used with OpenGL ES 2.0. Question: How do create and rotate a Quaternion with the following code? I have been reading up and studying about this and still can't quite gasp the concepts. I thought I understood it, but once I started making some calculations to rotate the quaternion I realized I can't even get back to where I started. So let us say that we have a cube, and the center of it is at (0, 0, 0). We want to rotate it on the x-axis by 45 degrees. What would I do? (Only the Quaternion) Assuming success, how would

When I have two orientation quaternions, how do I find the rotation quaternion needed to go from one to the other?

◇◆丶佛笑我妖孽 提交于 2019-12-04 11:47:42
问题 I'm using quaternions in my game, and I'm wondering how, when I have two orientation quaternions, I can get the rotation quaternion needed to go from the first one, q1, to the second one, q2. I'm self taught, so there may be obvious solutions missing from my vocabulary. In equations, what I'm doing when I rotate from the first one to the other is as follows: q2 = r * q1 However, now r is the unknown. Do the rules of algebra count here too? If that's the case, I'd end up dividing a quaternion

Compare device 3D orientation with the sun position

假如想象 提交于 2019-12-04 10:24:43
I am working on an app that requires the user to aim his iPhone to the sun in order to trigger a special event. I can retrieve the device 3D orientation quaternion based on the gyroscope and CoreMotion framework, from this I can get the yaw, roll and pitch angles. I can also compute the sun's azimuth and zenith angle based on the current date and time (GMT) and the latitude and longitude. What I am trying to figure out next is how to compare these two sets of values (phone orientation and sun position) to accurately detect the alignment of the device with the sun. Any ideas on how to achieve

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

限于喜欢 提交于 2019-12-04 08:39:25
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 this camera to handle all 6 degrees of movement in 3D space, and roll. Bearing, Pitch and Roll are all quaternions. I multiply them into a 'change' quaternion, and create a translation matrix from that. I put that in a float buffer, and multiply the modelview matrix by my buffer containing the rotation matrix. I can get the bearing and pitch rotations