0.1.1 • Published 4 years ago
@suns-echoes/math-utils v0.1.1
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](./docs/utils/geometry/calculate/distance.md) - calculate distance from point to origin * [sagitta](./docs/utils/geometry/calculate/sagitta.md) - calculate sagitta from radius and segment width * [sagittaFromAngle](./docs/utils/geometry/calculate/sagitta-from-angle.md) - calculate sagitta from radius and angle
Transformation
* [reflect](./docs/utils/geometry/transform/reflect.md) - reflect point over origin point * [reflectOverLine](./docs/utils/geometry/transform/reflect-over-line.md) - reflect point over line plotted by two points * [reflectX](./docs/utils/geometry/transform/reflect-x.md) - reflect point x coordinate over origin point * [reflectY](./docs/utils/geometry/transform/reflect-y.md) - reflect point y coordinate over origin point * [rotate](./docs/utils/geometry/transform/rotate.md) - rotate point around origin point * [scale](./docs/utils/geometry/transform/scale.md) - scale point x and y coordinates * [scaleX](./docs/utils/geometry/transform/scale-x.md) - scales point x coordinate * [scaleY](./docs/utils/geometry/transform/scale-y.md) - scales point y coordinate * [translate](./docs/utils/geometry/transform/translate.md) - translate point coordinates by vector * [translateX](./docs/utils/geometry/transform/translate-x.md) - translate point x coordinate by vector * [translateY](./docs/utils/geometry/transform/translate-y.md) - 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