JimAnkrom / sway

App-free, multi-user, device-agnostic control systems. Translate smartphone sensor data into control data (OSC, WebSockets for now - future with MIDI, DMX?).
14 stars 4 forks source link

As a sway user, my orientation should be the same in reference to the installation for both absolute and relative orientations. #49

Open JimAnkrom opened 9 years ago

JimAnkrom commented 9 years ago

Non-absolute devices must translate to an absolute position.

Some links http://stackoverflow.com/questions/18112729/calculate-compass-heading-from-deviceorientation-event-api

Dewb commented 9 years ago

So that stackoverflow link describes how to calculate a total compass heading, taking into account all the device orientation data. We don't need a fully calculated compass heading that incorporates beta/gamma, we just need an alpha value that's zero-centered on magnetic north.

Perhaps event.webkitCompassHeading is performing a similar calculation. If the simple fix of subbing alpha for webkitCompassHeading doesn't produce the correct results, maybe what we need to do is to perform the reverse of the SO calculation on wkCH to separate out beta and gamma, and just identify the original absolute alpha.

JimAnkrom commented 9 years ago

Yeah, I was thinking about the latter. Apologies for using issues here a bit as a scratchpad. :)

Webkit does seem to offer us some options. I plan to eval better when I get back to my dev environments.

Dewb commented 9 years ago

Issues as scratchpad is totally appropriate!