JSPM

@lgs-code/2d-geometry

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q39093F
  • License MIT

TypeScript library for 2d geometry

Package Exports

  • @lgs-code/2d-geometry
  • @lgs-code/2d-geometry/dist/2d-geometry.js
  • @lgs-code/2d-geometry/dist/2d-geometry.mjs
  • @lgs-code/2d-geometry/dist/2d-geometry.umd

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lgs-code/2d-geometry) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

2d-geometry

2d-geometry is a (yet another) library providing a bunch of classes and geometry operations in 2d space.

The main concern behind this library is to aggregate at some point, as many neat computational features that we can do for basic shapes in 2d space as possible.

This library is not intented to be used as-is, but more as a toolkit in your own applications.

How to use it

For example, image you'd like to get the area of a circle, you could use the following code :

import { Circle2d, Point2d }  from "@lgs-code/2d-geometry"; 

const circle = new Circle2d(new Point2d(10, 10), 33);

// will output 3421.19
console.log(circle.area);

Another example could be you'd like to get intersection points between an ellipse and a rectangle, you could use the following code :

import { Rect2d, Ellipse2d }  from "@lgs-code/2d-geometry"; 

const rect = new Rect2d(new Point2d(0, 0), 150, 30);
const ellipse = new Ellipse2d(new Point2d(20, 10), 100, 60);

// will output [ Point2d { x: 67.14, y: 0 }, Point2d { x: 57.27, y: 30 } ]
const intersections = rect.getIntersectionPoints(ellipse);

Fairly simple, right?

Documentation

For the list of of available classes and features, please review the documentation here.

Tools

The tools used in this library are :

  • TypeScript => mostly for configuring compiler options
  • ESLint => code rules and formatters
  • Prettier => code formatting rules
  • Rollup => to create bundles in various format like UMD, Common Js and ES Modules
  • Jest => writing and executing unit tests
  • TypeDoc => generating the documentation

Contribution

Feel free to contribute by adding new features or shapes :)