GyroPlane - Project angles from a gyroscope onto a 2D plane.
This library provides a way to project 3D angles from a gyroscope (e.g. from a
smartphone) onto a 2D plane. Basically it "converts" the alpha and beta values
to x and y coordinates.
The library needs to be aware of the plane size (in pixels) and the distance
between the center of the plane and the center of the gyroscope. The distance
is also defined in pixels.
How to use
import { GyroPlane } from 'gyro-plane'
const width = window.innerWidth
const height = window.innerHeight
const distance = width * 2
let gyro = new GyroPlane({
width: window.innerWidth,
height: window.innerHeight,
distance: distance
})
gyro.updateOrientation({ alpha: 30, beta: -25.6 })
const coordinates = gyro.getScreenCoordinates()
Todo