quaternions

Arcball Rotation with Quaternions (using iOS GLKit)

纵饮孤独 提交于 2019-12-02 21:23:15
I'm looking for a simple implementation for arcball rotation on 3D models with quaternions, specifically using GLKit on iOS . So far, I have examined the following sources: Arcball rotation with GLKit How to rotate a 3D object with touches using OpenGL I've also been trying to understand source code and maths from here and here . I can rotate my object but it keeps jumping around at certain angles, so I fear gimbal lock is at play. I'm using gesture recognizers to control the rotations (pan gestures affect roll and yaw, rotate gestures affect pitch). I'm attaching my code for the quaternion

Split quaternion into axis rotations

為{幸葍}努か 提交于 2019-12-02 17:49:01
问题 I have a quaternion representing the orientantion of an object (yellow box and sphere). I would like to know if it is possible to split that quaternion into other quaternions that give us the rotation of each local axis (X, Y and Z). What I have been doing until now is getting the Euler representation and work with it, but it is not the correct solution for my particular case: Given two points (blue boxes), I want to limit the orientation of my object so that it can't point out of the grey

Extracting Yaw from a Quaternion

馋奶兔 提交于 2019-12-02 15:13:46
I have a rotation quaternion and want to extract the angle of rotation about the Up axis (the yaw). I am using XNA and as far as I can tell there is no inbuilt function for this. What is the best way to do this? Thanks for any help, Venatu The quaternion representation of rotation is a variation on axis and angle. So if you rotate by r radians around axis x , y , z , then your quaternion q is: q[0] = cos(r/2); q[1] = sin(r/2)*x; q[2] = sin(r/2)*y; q[3] = sin(r/2)*z; If you want to create a quaternion that only rotates around the y axis, you zero out the x and z axes and then re-normalize the

Constrain pitch, yaw, & roll

我的梦境 提交于 2019-12-02 09:54:16
问题 I've a rotation represented as a quaternion and am trying to constrain the pitch, yaw, & roll axes. I tried doing so thusly: public struct Orientation { public Vector3 up, forward; public Orientation(Vector3 up, Vector3 forward) { this.up = up; this.forward = forward; } } public static Orientation[] orientations = new Orientation[3] { new Orientation(Vector3.right, Vector3.up), new Orientation(Vector3.up, Vector3.forward), new Orientation(Vector3.forward, Vector3.right) }; public enum Axis {

Split quaternion into axis rotations

爷,独闯天下 提交于 2019-12-02 08:58:05
I have a quaternion representing the orientantion of an object (yellow box and sphere). I would like to know if it is possible to split that quaternion into other quaternions that give us the rotation of each local axis (X, Y and Z). What I have been doing until now is getting the Euler representation and work with it, but it is not the correct solution for my particular case: Given two points (blue boxes), I want to limit the orientation of my object so that it can't point out of the grey plane, even if my quaternion looks out of that plane. I want to split (decompose) the quaternion, because

Unity3d - eulerAngles (local and global) totally different than what's in inspector

余生颓废 提交于 2019-12-01 22:08:13
问题 In the inspector for a gameObject I'm using the starting rotation is "-90", but when I run print(transform.eulerAngles.x) I get 270 (ditto for transform.localEulerAngles.x ). If I tilt the gameObject downward, the inspector X value gets bigger (say, to -85) as it should. The printed transform.eulerAngles.x also gets bigger, say to 274. Here's where things get weird: If I tilt the gameObject upward the inspector x coordinate gets smaller (ex, to -95), as it should, BUT the printed eulerAngle.x

Unity3d - eulerAngles (local and global) totally different than what's in inspector

南楼画角 提交于 2019-12-01 20:59:29
In the inspector for a gameObject I'm using the starting rotation is "-90", but when I run print(transform.eulerAngles.x) I get 270 (ditto for transform.localEulerAngles.x ). If I tilt the gameObject downward, the inspector X value gets bigger (say, to -85) as it should. The printed transform.eulerAngles.x also gets bigger, say to 274. Here's where things get weird: If I tilt the gameObject upward the inspector x coordinate gets smaller (ex, to -95), as it should, BUT the printed eulerAngle.x value gets BIGGER (here to 274). So if I rotate the object up or down from the eulerAngle.x being 270,

Incorrect conversion from quaternions to euler angles and back

僤鯓⒐⒋嵵緔 提交于 2019-12-01 20:45:13
I am converting angles-axis representation to Euler angles. I decided to check and make sure that the Euler angles I got from the conversion would lead back to the original axis-angle. I print out the values, but they do not match! I have read http://forum.onlineconversion.com/showthread.php?t=5408 and http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles as well as similar conversion questions on this website. In the code below I start with angle 'angle' and axis (rx,ry,rz), then I convert it to quaternions (q0,q1,q2,q3). I convert the quaternions to euler angles (roll,

Calculate Quaternion Inverse [closed]

て烟熏妆下的殇ゞ 提交于 2019-12-01 16:37:06
Hi i'm trying to figure out how to calculate the inverse of a quaternion. A code example would be awesome. Cheers Mihai Maruseac See Wikipedia article for the entire Quaternion math. Don't know what language you want to use but I'll try to give some hints in Haskell. data Quaternion = Q Double Double Double Double deriving (Show, Eq) First, you need to implement multiplication and addition of quaternions. instance Num Quaternion where (+) = q_plus (*) = q_mult --.... q_plus (Q a b c d) (Q a' b' c' d') = Q (a + a') (b + b') (c + c') (d + d') q_mult (Q a b c d) (Q a' b' c' d') = Q a'' b'' c'' d'

opengl matrix rotation quaternions

元气小坏坏 提交于 2019-12-01 15:53:08
问题 Im trying to do a simple rotation of a cube about the x and y axis: I want to always rotate the cube over the x axis by an amount x and rotate the cube over the yaxis by an amount y independent of the x axis rotation first i naively did : glRotatef(x,1,0,0); glRotatef(y,0,1,0); then but that first rotates over x then rotates over y i want to rotate over the y independently of the x access. I started looking into quaternions, so i tried : Quaternion Rotation1; Rotation1.createFromAxisAngle(0,1