Giter Club home page Giter Club logo

euclid.js's Introduction

Euclid.ts

Build Status npm npm

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.

API

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)

Usage

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'

Contributing

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 and License

Copyright © Mathigon ([email protected])
Released under the MIT license

euclid.js's People

Contributors

plegner avatar renovate[bot] avatar renovate-bot avatar pjhenning avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.