@suns-echoes/math-utils
v0.1.1
Published
Math Utilities Library
Downloads
1
Readme
Math Utilities
math-utils
library add new mathematical functions and constants.
Installation
npm i @suns-echoes/math-utils
Import
as Node.js module (CJS)
// Import full library minimized distribution file:
import MathUtils from '@suns-echoes/math-utils';
// Import library from source:
import MathUtils from '@suns-echoes/math-utils/cjs';
// or named:
import { MathUtils } from '@suns-echoes/math-utils/cjs/math-utils';
// Import single util:
import { sagitta } from '@suns-echoes/math-utils/cjs/utils/geometry-2d/calculate/sagitta';
as ES6 module (ESM)
// Import library from source:
import MathUtils from '@suns-echoes/math-utils/esm/index.js';
// or named:
import { MathUtils } from '@suns-echoes/math-utils/esm/math-utils.js';
// Import single util:
import { sagitta } from '@suns-echoes/math-utils/esm/utils/geometry-2d/calculate/sagitta.js';
Constants
- ORIGIN_0x0 - Origin of the coordinate system
- FIX_FLOAT - Default and maximum precision of fixFloat method
Check
- isPoint - check if the thing is a Point
- isVector - check if the thing is a Vector
- pointEqualPoint - check if two points have the same coordinates
Conversion functions
Geometry functions
Calculation
- distance - calculate distance from point to origin
- sagitta - calculate sagitta from radius and segment width
- sagittaFromAngle - calculate sagitta from radius and angle
Transformation
- reflect - reflect point over origin point
- reflectOverLine - reflect point over line plotted by two points
- reflectX - reflect point x coordinate over origin point
- reflectY - reflect point y coordinate over origin point
- rotate - rotate point around origin point
- scale - scale point x and y coordinates
- scaleX - scales point x coordinate
- scaleY - scales point y coordinate
- translate - translate point coordinates by vector
- translateX - translate point x coordinate by vector
- translateY - translate point y coordinate by vector
Trigonometry functions
- angleBetweenTreePoints - calculate angle between 3 points
- cos - calculate cosine value
- sin - calculate sine value
- tan - calculate tangent value
- versin - versus sine value
Tools
- fixFloat - fix float rounding precision error
- setFixFloatPrecision - set precision for fixFloat method
License
Licensed under MIT
Copyright (c) 2020 Aneta Suns