@schwingbat/relative-angle

1.0.0 • Public • Published

relative-angle

Calculate the angle between two sets of XY coordinates. Useful for getting the angle of the mouse from a particular object on screen, for example.

const getDegrees = require("@schwingbat/relative-angle").degrees;
const getRadians = require("@schwingbat/relative-angle").radians;

const pointOne = {
	x: 612,
	y: 314
}

const pointTwo = {
	x: 1128,
	y: 851
}

console.log(getDegrees(pointOne, pointTwo)); // 46.14249942304433 degrees
console.log(getRadians(pointOne, pointTwo)); // 0.8053385400317074 radians

/@schwingbat/relative-angle/

    Package Sidebar

    Install

    npm i @schwingbat/relative-angle

    Weekly Downloads

    22

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • schwingbat