Skip to content

benevolent-games/math

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

57 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

@benev/math

benevolent's typescript math library for games


πŸ‹ CORE

common numerical structures

Tip

until real docs are written, see the relevant sourcecode in s/core/

🍏 conventions for all core classes

  • mutable by default.
    operations happen in-place, for efficiency (we're trying to reduce gc churn).
    // allocate a single vector instance
    const vector = new Vec2(0, 0)
      .add({x: 1, y: 2})
      .multiplyBy(2)
  • explicit cloning.
    use .clone() to avoid mutating the original.
    // modify a clone (not the original)
    const vector2 = vector
      .clone()
      .normalize()
  • underscore-suffixed methods take direct args.
    • methods normally take in other class instances:
      vectorA.add(vectorB)
    • but underscore-suffixed methods take raw naked args (helping you avoid making instances)
      vectorA.add_(x, y)

🍏 Vec2

🍏 Vec3

🍏 Vec4

🍏 Quat


πŸ‹ TOOLS

handy utilities

Tip

until real docs are written, see the relevant sourcecode in s/tools/

🍏 Scalar

🍏 Circular

🍏 Randy

🍏 Noise

🍏 Spline

🍏 Angles

  • Radians
  • Degrees
  • Turns
  • Arcseconds

πŸ‹ SHAPES

geometric concepts

Tip

until real docs are written, see the relevant sourcecode in s/shapes/

🍏 2d shapes

  • Edge β€” a line segment
  • Pill β€” a fat line segment (like a sausage)
  • Rect β€” a rectangle
  • Circle β€” a point with a radius

🍏 3d shapes

  • Segment β€” a line segment
  • Capsule β€” a fat line segment (like a hoagie)
  • Box β€” a cuboid
  • Sphere β€” a point with a radius

πŸ‹ OPTIMIZERS

spatial optimization data structures

Tip

until real docs are written, see the relevant sourcecode in s/optimizers/

🍏 HashMap

🍏 HashSet

🍏 ZenGrid


πŸ‹ PHYSICS

functionality for doing basic physics

Tip

until real docs are written, see the relevant sourcecode in s/physics/

🍏 collide2d

🍏 collide3d

🍏 intersect2d

🍏 intersect3d


star this on github if you use it πŸ‘

About

ts math utils for games

Resources

License

Stars

Watchers

Forks

Packages

No packages published