https://github.com/thormeier/gyro-plane
https://github.com/thormeier/gyro-plane
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/thormeier/gyro-plane
- Owner: thormeier
- License: mit
- Created: 2018-11-14T18:07:39.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-14T18:24:10.000Z (over 7 years ago)
- Last Synced: 2025-03-17T11:55:01.315Z (over 1 year ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```javascript
import { GyroPlane } from 'gyro-plane'
const width = window.innerWidth
const height = window.innerHeight
// Assume the distance between gyroscope and screen to be two times the width
const distance = width * 2
let gyro = new GyroPlane({
width: window.innerWidth,
height: window.innerHeight,
distance: distance
})
// Update the orientation values from a gyroscope.
gyro.updateOrientation({ alpha: 30, beta: -25.6 })
// To get the calculated coordinates, you have to call this function.
const coordinates = gyro.getScreenCoordinates()
// => { x: 80, y: 130 }
```
## Todo
- docs
- tests