npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

geometric-pack

v0.7.1

Published

Geometric pack with lots of available calculations for 2D and 3D geometry

Downloads

381

Readme

Geometric pack

Geometric calculator created with TypeScript

The package supports accuracy up to 12 decimal places.

Table of contents

General info

Geometric pack with lots of available calculations for 2D and 3D geometry

Example

import { Triangle } from "geometric-pack";

const firstTriangle = new Triangle(5, 3, 4);
const secondTriangle = new Triangle(10, 6, 8);

console.log(firstTriangle.isCongruent(secondTriangle)); // False
console.log(firstTriangle.isSimilar(secondTriangle)); // True

You can also check more examples by running .getDefinition() method on other classes or by running example file

$ node node_modules/geometric-pack/dist/utils/example

Launch

To use available calculations in this project you will have to create object of class you want to use and start available methods

import { Triangle } from "geometric-pack";

const firstTriangle = new Triangle(5, 3, 4);

console.log(firstTriangle.getDefinition());

// returns:
// {
//   sideLengthA: 3,
//   sideLengthB: 4,
//   sideLengthC: 5,
//   circumference: 12,
//   area: 6,
//   rightAngle: true,
//   heights: { heightOfBaseA: 4, heightOfBaseB: 3, heightOfBaseC: 2.4 },
//   angles: { gamma: 90, beta: 53.13010235415598, alpha: 36.86989764584402 },
//   outerCircleRadius: 2.5,
//   innerCircleRadius: 1
// }

Available classes:

  • Two-dimensional

    • Triangle, You have to use three arguments and program will take them as a sides of triangle 'a', 'b', 'c', you can write them in any order you want because program will sort them a < b < c

    • Rectangle, You have to use two arguments and program will take them as a sides of rectangle 'a', 'b', program will not sort them in any order

    • Square, You have to use one argument and program will take it as a side of square 'a'

    • Circle, You have to use one argument and program will take it as a radius of circle 'r'

    • Rhombus, You have to use two arguments and program will take them as side 'a' and height 'h' in exact order

    • Parallelogram, You have to use three arguments and program will take them as side 'a', side 'b' and height 'h' in exact order

    • Polygon, It's a regular polygon so you have to use two arguments and program will take them as side 'a' and number of sides 'n' where 3 <= n <= 14 in exact order

    • Stadium, You have to use two arguments and program will take them as side length 'a' and radius 'r' in exact order

    • Distance2D, You have to use four arguments and program will take them as coordinates 'x1', 'y1', 'x2', 'y2' in exact order

    • Annulus, You have to use two arguments and program will take them as outerRadius 'r1' and innerRadius 'r2' in exact order

    • QuadraticFunction, You have two use three arguments and program will take them as 'a', 'b' and 'c' of function in exact order

    • LinearFunction, You have to use two arguments and program will take them as 'a' and 'b' of function in exact order

  • Three-dimensional

    • Cone, You have to use two arguments and program will take them as radius 'r' and height 'h' in exact order

    • Cylinder, You have to use two arguments and program will take them as radius 'r' and height 'h' in exact order

    • Sphere, You have to use one argument and program will take it as radius 'r'

    • Cube, You have to use one argument and program will take it as length side 'a'

    • ConicalFrustum, You have to use three arguments and program will take them as radius1 'r1', radius2 'r2' and height 'h' in exact order

    • Capsule, You have to use two arguments and program will take them as sideLength 'a' and radius 'r' in exact order

    • Hemisphere, You have to use two one argument and program will take it as radius 'r'

    • Pyramid, You have to use two arguments and program will take them as side length 'a' and height 'h' in exact order

    • Cuboid, You have to use three arguments and program will take them as length 'l', width 'w' and height 'h' in exact order

    • Distance3D, You have to use six arguments and program will take them as coordinates 'x1', 'y1', 'z1', 'x2', 'y2', 'z2' in exact order

    • Tube, You have to use three arguments and program will take them as outerRadius 'r1', innerRadius 'r2' and height 'h' in exact order

    Setup

    To run this project, install it locally using npm

    $ cd ../lorem
    $ npm init
    $ npm i geometric-pack

    Technologies

    Project is created with:

    • TypeScript: 4.3.5