Skip to content

Mathematical Utilities (conversion, geometry, trigonometry, and more ...).

License

Notifications You must be signed in to change notification settings

suns-echoes/math-utils

Repository files navigation

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

Conversion functions

  • degToRad - convert angle in degrees to radians
  • radToDeg - convert angle in radians into degrees

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

Tools

License

Licensed under MIT

Copyright (c) 2020 Aneta Suns

About

Mathematical Utilities (conversion, geometry, trigonometry, and more ...).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published