geom2.js - an Open Source JS Library for 2D Geometry Calculation

We proudly announce geom2.js an open source, high performance library for 2D Geometry Calculation. In Staroyale.io, it's used for collision detection and artificial intelligence (steering and path finding), server-client viewport optimization.

geom2.js - an Open Source JS Library for 2D Geometry Calculation

We proudly announce geom2.js an open source, high performance library for 2D Geometry Calculation written in TypeScript.

In Staroyale.io, it's used for collision detection and artificial intelligence (steering and path finding), server-client viewport optimization. But I think you guys will find it useful in other situations.

We extract the server-side code of Staroyale.io to make it a standard alone library, because we think other gamedevs probably love it too.

Difference from Physics Engines

Most physics engines bundles all the physics related data structure and algorithm together. It makes setup easy but it limits the flexibility of the application or games. Because in lots of scenario except physics simulation, objects are not intended to move according to physics laws.

This library is much more light-weight than a physics engine, and it gives users a more control over their own 2d world.

NPM Install

npm install geom2.js

Structure:

  • Vector
  • Segment
  • Shap
    • AABB (Axis-Aligned Bounding Box)
    • Arc
    • Circle
    • Polygon

Algorithm:

  • Common
    • Collision detection between shapes.
      • GJK (Gilbert–Johnson–Keerthi)
      • SAT (Separation Axis Theorem)
    • Convex Polygon test
    • Convex Hull
  • Generation
    • Random convex polygon generation
  • Advance
    • Field of view scanning (line sweeping)

Container:

  • Loose QuadTree
    • High-quality quadtree implementation
    • It can store AABB (Axis-Aligned Bounding Box).
    • No elements on branch nodes, all data on leaves.
    • It maintains loose boundary on all nodes.
    • It outperforms simple-quadtree and all other available js quadtree.

Addition Feature:

  • Physics Collision Resolution