Accessing your device's sensors

Here's a project that accesses sensors (on a phone or laptop).

Accesses 9 different sensors if permission is granted and supported by your device. They are
x acceleration
y acceleration
z acceleration
x axis rotation
y axis rotation
z axis rotation (compass direction)

Sensors are available in iframes only if explicitly allowed by the container.


Send questions, suggestions, bug reports to

Javascript uses quaternions? I thought linear algebra had made them obsolete. Can you teach me more about how they're used?

They are used to model (and implement) rotations. The Euler angles are much simpler but seem to suffer from Gimbal Lock which quaternions solve.

Besides being used in orientation sensors it seems they are used on the web to represent points -

I only half understand this.

Background for those who don't know what we are talking about: Browsers can report the orientation of a device. The old way reported rotations around x, y, and z while the new API reports a quaternion.

I think this paper is what started it all:

Ken Shoemake. 1985. Animating rotation with quaternion curves. In Proceedings of the 12th annual conference on Computer graphics and interactive techniques ( SIGGRAPH ’85 ). Association for Computing Machinery, New York, NY, USA, 245–254. DOI:

Better than I've managed, following Wikipedia links. I know nothing about algebra! As a teenager I naively thought that groups and fields pretty much covered it, but apparently not.

When I was 12-15 years old I could just eat this stuff up. Now I get a headache looking at it. So one or both of (1) my brain cells are dying, or (2) the stuff I was eating up back then was the low-hanging fruit. But I think it's more (1); I took a course on Hilbert spaces at 14, and point set topology at 15, and understood them. Sigh.

I feel the like (1) as well. Though sometimes I feel like what I'm not understanding is the underlying reasoning when I see mathematics in a paper. I know what the operators do, I can compute it, but I struggle to get the underlying intuitions. Often I think authors don't try enough.

Perhaps it is more performant than linear algebra as that might require the creation of rotation matrices and matrix multiplication operations, etc
Also they are easier to understand on youtube, but it is hard since they are 4D and thus don't really have any visual representation.