Skip to content

ryohidaka/compass-heading-js

Repository files navigation

compass-heading-js

npm version License

Overview

Converts device orientation to compass heading.

Installation

You can install this library using npm:

npm install compass-heading-js

Props

key descriptiion
alpha The device's compass heading
beta the device's tilt front-to-back
gamma the device's tilt left-to-right

Usage

import { calculateCompassHeading } from "compass-heading-js";

const alpha = 45;
const beta = 30;
const gamma = 60;

const heading = calculateCompassHeading(alpha, beta, gamma);
console.log(heading);
// Output: 260.76847951640775

License

This project is licensed under the MIT License - see the LICENSE file for details.