ios - iPhone rotation quaternion absolute coordinates? -


i have iphone gyroscope.

let's have quaternion of phone rotation q.

i want show points on screen relative of world absolute coordinates. every rotation of phone points "still" in real 3d space (sort of augmented reality). let's 4 points forming rectangle.

so have created 4 points in 3d space relative phone screen , apply transformation of q each of it.

i thought should simple points transformed not relative world coordinates coordinates don't understand, may phone axis related?. please me this? need create new view on screen projection virtual points in absolute 3d space rotated camera.

my rotation results seems right long not rotating phone along 'normal' axis (perpendicular screen). rotation on direction results in wrong points translation.

pseudocode included.

motionmanager.startdevicemotionupdates

        quaternion q;//quaternion read cmattitude above, relative frame: xarbitraryzvertical         var qi=q.conjugate;          var vx = new vector3d (-1, 0, 2);         var vy = new vector3d (1, 0, 2);         var vz = new vector3d (1, 0, -2);         var vw = new vector3d (-1, 0, -2);          var vxn=vector3d.transform(vx,qi);         var vyn=vector3d.transform(vx,qi);         var vzn=vector3d.transform(vx,qi);         var vwn=vector3d.transform(vw,qi);          var convertpixels = 50;          vxn = vxn * convertpixels;         vyn = vyn * convertpixels;         vzn = vzn * convertpixels;         vwn = vwn * convertpixels;          //screen projection          x.frame = new rectanglef (new pointf ((float)(videoarea.width / 2 + vxn.x), (float)(videoarea.height / 2 + vxn.z)), new sizef (10, 10));         y.frame = new rectanglef (new pointf ((float)(videoarea.width / 2 + vyn.x), (float)(videoarea.height / 2 + vyn.z)), new sizef (10, 10));         z.frame = new rectanglef (new pointf ((float)(videoarea.width / 2 + vzn.x), (float)(videoarea.height / 2 + vzn.z)), new sizef (10, 10));         w.frame = new rectanglef (new pointf ((float)(videoarea.width / 2 + vwn.x), (float)(videoarea.height / 2 + vwn.z)), new sizef (10, 10)); 

finally done opengl matrices. use multiplication of rotation matrix given phone , generated projection matrix. key feature transforming coordinates of rotation iphone opengl (right handed left-handed). got new axis of rotation -x , -y, created new rotation matrix new axis , angle. , matrix gives me right results.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -