@benev/math
v0.2.0
Published
game math toolkit
Downloads
176
Readme
@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)
- methods normally take in other class instances:
🍏 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
👼 https://benevolent.games/
star this on github if you use it 👍
