w3c / orientation-sensor

Orientation Sensor
https://www.w3.org/TR/orientation-sensor/
Other
12 stars 21 forks source link

Automation: integrate with Device Orientation API's Automation section #83

Closed rakuco closed 8 months ago

rakuco commented 9 months ago

This PR builds upon w3c/deviceorientation#124 by augmenting the "parse orientation data reading" algorithm and making it also support quaternions in addition to Euler angles.

From the third and biggest commit:

Both the Device Orientation API and the Orientation Sensor specifications provide orientation data. Among other differences, the former provides the data as a set of intrinsic Tait-Bryant Euler angles, whereas the latter uses quaternions.

From an automation perspective, though, it makes sense to use the same virtual sensor types for both APIs and take care of the conversions internally.

The Device Orientation spec's Automation section defines steps for parsing a user-provided reading as alpha, beta, gamma numbers that adhere to the requirements laid out by the same spec. This commit augments the same "parse orientation data reading" algorithm by also setting a "quaternion" entry in the reading map that is derived from the user-provider Euler angles.

The Euler angles to quaternion algorithm has been copied from Chromium.


Preview | Diff

rakuco commented 9 months ago

@reillyeon PTAL. https://github.com/w3c/deviceorientation/pull/124#discussion_r1416152075 has more context.