UNPKG

math-base-geometry

Version:

utils for math geometry

47 lines (33 loc) 1.1 kB
# math-base-geometry ### Installation and use Install npm packages: ``` npm i math-base-geometry ``` ### Short description There are two types of shapes available: * Two-dimensional (2d) * Three-dimensional (3d) Available for now: * 3d: Sphere, Cylinder * 2d: Circle, Triangle ### Usage import MathGeom from "math-base-geometry"; const twoDimension = MathBaseGeometry.twoDim; const triDimension = MathBaseGeometry.triDim; const Sphere = triDimension.Sphere; //result with 3 decimals const R = 5; const DECIMAL_LIMIT = 3; console.log(Sphere.surfaceArea(R, DECIMAL_LIMIT)); //314.159 //result with no decimals limit console.log(Sphere.surfaceArea(5)); //314.1592653589793 const Triangle = twoDimension.Triangle; //result with 2 decimals; const SIDE_1 = 2.5; const SIDE_2 = 4.47939; const SIDE_3 = 4.5; const DECIMAL_LIMIT = 3; console.log(Triangle.perimeter(SIDE_1, SIDE_2, SIDE_3, DECIMAL_LIMIT)); //11.479 //result with no decimal limit console.log(Triangle.perimeter(SIDE_1, SIDE_2, SIDE_3)); //11.47939