New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gyro-plane

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gyro-plane

Transform angle values from a gyroscope to 2D coordinates.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

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

// 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

Keywords

FAQs

Package last updated on 14 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc