Euler angles, an optimal solution ?

Hi!

The device orientation spec
http://dev.w3.org/geo/api/spec-source-orientation.html uses Euler
angles.

But is this an optimal solution ? While it seems trivial to
understand, manipulating angles is quite cumbersome, because before
being used, angles need to be converted into a transformation matrix
using something not trivial
http://en.wikipedia.org/wiki/Rotation_matrix#General_rotations
Context switching between all those arithemetic and trigonometric
operations, and machine code can hinder performance quite
significantly, given that a orientationchange event can be dispatched
a couple hundred times a second.

So, I would suggest one of the following:
 - provide a transformation matrix together with the 3 angles
 - provide an API to convert the 3 angles into a transformation matrix

Device orientation can too be represented using two vectors, v and n,
being v, parallel to the surface, say, pointing in the direction of
the y axis, and n perpendicular to the surface. n would give the
surface tilt and v the rotation along its z axis. So, the
transformation matrix could be multiplied against (0,1,0) or (0,0,1)
to get one of these two vectors, or used directly in any of the other
operations.

Thank you for your time.

Received on Monday, 14 March 2011 15:53:10 UTC