@bedard/math

This library exists to help me avoid duplicate code between projects. My goal is to expose small, well tested, and tree-shakeable utility functions. Given the simplicity of these, I do not anticipate breaking changes. But be warned, this project is not following semantic versioning.
Installation
The recommended installation method is via NPM.
npm install @bedard/math
Alternatively, these functions maybe be accessed via a CDN. When using a CDN, the library will be exposed globally as BedardMath
.
<script src="https://unpkg.com/@bedard/math"></script>
Functions
angleFrom
Calculate angled distance from a vector. An angle of 0
degrees will track along the X axis, with positive angles rotating counter-clockwise.
import { angleFrom } from '@bedard/math'
angleFrom([0, 0], 90, 1)
bilerp
Bi-linear interpolation between vectors.
import { bilerp } from '@bedard/math'
bilerp([0, 0], [10, 10], 0.5)
degreesToRadians
Convert degrees to radians.
import { degreesToRadians } from '@bedard/math'
degreesToRadians(180)
isEven
Test if a number is even.
import { isEven } from '@bedard/math'
isEven(2)
lerp
Linear interpolation between numbers.
import { lerp } from '@bedard/math'
lerp(0, 10, 0.5)
measure
Measure the distance between two vectors.
import { measure } from '@bedard/math'
lerp([0, 0], [3, 4])
radiansToDegrees
Convert radians to degrees.
radiansToDegrees(Math.PI)
License
MIT
Copyright (c) 2021-present, Scott Bedard