- From: Tim Volodine <timvolodine@google.com>
- Date: Wed, 16 Jul 2014 15:29:20 +0100
- To: public-geolocation <public-geolocation@w3.org>
- Cc: Rich Tibbett <richt@opera.com>, Rob Manson <roBman@buildar.com>, Giridhar Mandyam <mandyam@quicinc.com>
- Message-ID: <CAJv4RS3FX3=cx2VJdXCHdodPs2VkS5G6SFmPRfmHZb+PiWnkGw@mail.gmail.com>
Currently Device Orientation API provides an Euler angles based representation, which in practice suffers from a number of issues as summarized below. Hence this proposal to add a quaternion representation to the device orientation event. A unit quaternion represents a rotation of A radians around the unit vector [nx, ny, nz] : q = [x y z w] = [ nx*sin(A/2) ny*sin(A/2) nz*sin(A/2) cos(A/2) ]. Here are some considerations why this is useful: 1. Because Euler angles representations are difficult to compose developers often end up converting them to other representations like quaternions or rotation matrices. This extra conversion seems unnecessary especially on platforms where the Euler angles are obtained via a quaternion representation in the first place, e.g. on Android. 2. Using quaternion representation it is significantly easier to compute 'screen adjusted' orientation, i.e. taking into account the portrait/landscape orientation of the actual page (using the Screen Orientation API). 3. Intrinsic Euler rotations tend to have implementations that are not always consistent. For example currently Safari and Firefox don't follow the specification for some positions. 4. Euler angles have an additional degree of freedom when beta=+-90 degrees (so-called gimbal lock situation), making multiple angle combinations all correspond to the same orientation in space. Proposed interface changes: [Callback, NoInterfaceObject] interface OrientationQuaternion { readonly attribute double x; readonly attribute double y; readonly attribute double z; readonly attribute double w; } [Constructor(DOMString type, optional DeviceOrientationEventInit eventInitDict)] interface DeviceOrientationEvent : Event { readonly attribute double? alpha; readonly attribute double? beta; readonly attribute double? gamma; readonly attribute boolean absolute; readonly attribute OrientationQuaternion? quaternion; } Tim
Received on Wednesday, 16 July 2014 14:30:17 UTC