0.4.0 • Published 1 year ago

@evojs/math v0.4.0

Weekly downloads
1
License
MIT
Repository
github
Last release
1 year ago

@evojs/math

Math extension for nodejs

@evojs/math npm version supported node version for @evojs/math total npm downloads for @evojs/math monthly npm downloads for @evojs/math npm licence for @evojs/math

Usage example

import '@evojs/math';

// Math.floor

console.log(Math.floor(Math.E)); // 2.718281828459045 -> 2
console.log(Math.floor(Math.E, 2)); // 2.718281828459045 -> 2.71

// Math.round

console.log(Math.round(Math.PI)); // 3.141592653589793 -> 4
console.log(Math.round(Math.PI, 2)); // 3.141592653589793 -> 3.14

// Math.ceil

console.log(Math.ceil(1.00001, 2)); // 1.00001 -> 1.01
console.log(Math.ceil(1.00001)); // 1.00001 -> 2

// Math.degrees

console.log(Math.degrees(Math.PI)); // 3.141592653589793 -> ~180

// Math.radians

console.log(Math.radians(180)); // 180 -> ~3.141592653589793

// Math.random

console.log(Math.random()); // random real [0, 1)
console.log(Math.random(100)); // random integers [0, 100)
console.log(Math.random(10, 100)); // random integers [10, 100)

// Math.sphereAngle

const locationA = { latitude: 0, longitude: 90 };
const locationB = { latitude: 90, longitude: 0 };

console.log(Math.sphereAngle(locationA, locationB)); // 90 degrees

// Math.sphereDistance

const EARTH_RADIUS = 6371; // km

const locationA = { latitude: 55.797416, longitude: 49.111374 };
const locationB = { latitude: 55.795997, longitude: 49.127173 };

console.log(Math.sphereDistance(EARTH_RADIUS, locationA, locationB)); // ~1km

License

Licensed under MIT license

0.4.0

1 year ago

0.3.0

2 years ago

0.1.0

3 years ago

0.0.0

4 years ago