![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@mathigon/euclid
Advanced tools
Euclid.ts is a Typescript library for 2D geometry. It contains classes for elements like points, lines, circles, and polygons, intersection detection, as well as SVG and Canvas drawing tools. It was developed for Mathigon.org, an award-winning mathematics education project.
All class instances are immutable: you need to create new copies rather than modifying their properties. This is mainly to facilitate fast change detection on downstream libraries.
Points: Point(x: number, y: number)
Lines: Line(p1: Point, p2: Point)
, Segment(p1: Point, p2: Point)
, Ray(p1: Point, p2: Point)
Polygons: Polygon(...points: Point[])
, Polyline(...points: Point[])
Rectangles: Rectangle(p: Point, w: number, h: number)
Circles: Circle(c: Point, r: number)
Ellipses: Ellipse(c: Point, a: number, b: number)
Arcs: Arc((c: Point, start: Point, angle: number))
, Sector((c: Point, start: Point, angle: number))
Angle: Angle(a: Point, b: Point, c: Point)
Bounds: Bounds(xMin: number, xMax: number, yMin: number, yMax: number)
Intersections: intsersection(...obj: GeoShape[])
Drawing: drawSVG(obj: GeoElement, options: SVGDrawingOptions)
, drawCanvas(ctx: CanvasRenderingContext2D, obj: GeoElement, options: CanvasDrawingOptions)
First, install Euclid.ts from NPM using
npm install @mathigon/euclid
Now, simply import all functions and classes you need, using
import {Point, Line} from '@mathigon/euclid'
We welcome community contributions: please file any bugs you find or send us pull requests with improvements. You can find out more on Mathigon.io.
Before submitting a pull request, you will need to sign the Mathigon Individual Contributor License Agreement.
Copyright © Mathigon (dev@mathigon.org)
Released under the MIT license
FAQs
Euclidean geometry classes and tools for JavaScript
The npm package @mathigon/euclid receives a total of 13,297 weekly downloads. As such, @mathigon/euclid popularity was classified as popular.
We found that @mathigon/euclid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.