math - Compute relative orientation given azimuth, pitch, and roll in android? -


when listen orientation event in android app, sensorevent, contains 3 floats - azimuth, pitch, , roll in relation real-world's axis.

now building app labyrinth, don't want force user on phone , hold phone such xy plane parallel ground. instead want able allow user hold phone wish, laying down or, perhaps, sitting down , holding phone @ angle. in other words, need calibrate phone in accordance user's preference.

how can that?

also note believe answer has getrotationmatrix , getorientation, not sure how!

please help! i've been stuck @ hours.

for labyrinth style app, care more acceleration (gravity) vector axes orientation. vector, in phone coordinate system, given combination of 3 accelerometers measurements, rather rotation angles. specifically, x , y readings should affect ball's motion.

if need orientation, 3 angular readings represent 3 euler angles. however, suspect don't need angles themselves, rather rotation matrix r, returned getrotationmatrix() api. once have matrix, is calibration looking for. when want transform vector in world coordinates device coordinates, should multiply inverse of matrix (where in special case, inv(r) = transpose(r).

so, following example found in documentation, if want transform world gravity vector g ([0 0 g]) device coordinates, multiply inv(r):

g = inv(r) * g

(note should give same result reading accelerometers)

possible apis use here: invertm() , multiplymv() methods of matrix class.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -