8000 GitHub - phun-ky/angle: A JavaScript function to calculate the angle between two coordinates
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ angle Public

A JavaScript function to calculate the angle between two coordinates

License

Notifications You must be signed in to change notification settings

phun-ky/angle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@phun-ky/angle

Commitizen friendly PRs Welcome SemVer 2.0 npm version issues license size npm GitHub Repo stars codecov build

About

A JavaScript function to calculate the angle between two coordinates.

Table of Contents

Installation

npm i --save @phun-ky/angle

Usage

Either import and run the required functions:

import { angle } from '@phun-ky/angle';

const angleValue = angle(0, 0, 3, 4);

console.log(angleValue); // 53.13

API

angle()

function angle(cx, cy, ex, ey, normalize?): number;

Defined in: main.ts:24

Returns the angle between two sets of coordinates.

Parameters

Parameter Type Default value Description
cx number undefined The x-coordinate of the first point.
cy number undefined The y-coordinate of the first point.
ex number undefined The x-coordinate of the second point.
ey number undefined The y-coordinate of the second point.
normalize? boolean true If the angle output should be normalized to a value between 0° and 360°.

Returns

number

The angle between the given coordinates.

Throws

Missing input for angle.

Throws

Parameters for angle do not have the required type.

Example

// Calculate the angle between two points
const angleValue = angle(0, 0, 3, 4);
console.log(angleValue); // 53.13
// Normalized
const angleValue = angle(0, 0, -3, -4, true);
console.log(angleValue); // 233.13

Full API documentation is available here.

Development

// Build
$ npm run build
// Run dev
$ npm run dev
// Test
$ npm test

Contributing

Want to contribute? Please read the CONTRIBUTING.md and CODE_OF_CONDUCT.md

License

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

Changelog

See the CHANGELOG.md for details on the latest updates.

Sponsor me

I'm an Open Source evangelist, creating stuff that does not exist yet to help get rid of secondary activities and to enhance systems already in 7BE2 place, be it documentation or web sites.

The sponsorship is an unique opportunity to alleviate more hours for me to maintain my projects, create new ones and contribute to the large community we're all part of :)

Support me on GitHub Sponsors.

Speccer banner, with logo and slogan: A zero dependency package to annotate or highlight elements

p.s. Ukraine is still under brutal Russian invasion. A lot of Ukrainian people are hurt, without shelter and need help. You can help in various ways, for instance, directly helping refugees, spreading awareness, putting pressure on your local government or companies. You can also support Ukraine by donating e.g. to Red Cross, Ukraine humanitarian organisation or donate Ambulances for Ukraine.

0