JSPM

@schwingbat/relative-angle

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 19
  • Score
    100M100P100Q56453F
  • License MIT

Calculate the angle from one set of XY coordinates to another in degrees or radians.

Package Exports

  • @schwingbat/relative-angle

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@schwingbat/relative-angle) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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