DOCS v0.1.13 github

@hatch:math v0.1.3

Vector + matrix + quaternion math — Vec2 / Vec3 / Vec4 / Mat4 / Quat, easings, and scalar helpers. Built for interactive apps and games.

stable system updated Apr 30, 2026 source ↗
README
$ hatch add @hatch:math

MOD math

CL Math

FN Math.static PI

FN Math.static TAU

FN Math.static HALF_PI

FN Math.static DEG_TO_RAD

FN Math.static RAD_TO_DEG

FN Math.static EPSILON

FN Math.static radians(deg)

FN Math.static degrees(rad)

FN Math.static lerp(a, b, t)

FN Math.static clampedLerp(a, b, t)

FN Math.static inverseLerp(a, b, v)

FN Math.static clamp(v, lo, hi)

FN Math.static saturate(v)

FN Math.static smoothstep(a, b, v)

FN Math.static smootherstep(a, b, v)

FN Math.static min(a, b)

FN Math.static max(a, b)

FN Math.static sign(v)

FN Math.static approxEq(a, b)

FN Math.static approxEq(a, b, eps)

FN Math.static wrap(v, lo, hi)

CL Ease

FN Ease.static linear(t)

FN Ease.static inQuad(t)

FN Ease.static outQuad(t)

FN Ease.static inOutQuad(t)

FN Ease.static inCubic(t)

FN Ease.static outCubic(t)

FN Ease.static inOutCubic(t)

FN Ease.static inBack(t)

FN Ease.static outBack(t)

FN Ease.static inExpo(t)

FN Ease.static outExpo(t)

CL Vec2

NEW Vec2.new(x, y)

GET Vec2.x

GET Vec2.y

SET Vec2.x=(v)

SET Vec2.y=(v)

GET Vec2.lengthSq

GET Vec2.length

GET Vec2.normalized

GET Vec2.toList

GET Vec2.data

GET Vec2.toString

FN Vec2.static zero

FN Vec2.static one

FN Vec2.static unitX

FN Vec2.static unitY

FN Vec2.+(other)

FN Vec2.-(other)

FN Vec2.*(other)

FN Vec2./(other)

FN Vec2.-

FN Vec2.dot(other)

FN Vec2.distanceSq(other)

FN Vec2.distance(other)

FN Vec2.cross(other)

FN Vec2.static lerp(a, b, t)

FN Vec2.addInto(a, b)

FN Vec2.subInto(a, b)

FN Vec2.mulIntoScalar(a, s)

FN Vec2.copyFrom(v)

FN Vec2.approxEq(other)

FN Vec2.approxEq(other, eps)

FN Vec2.==(other)

FN Vec2.!=(other)

CL Vec3

NEW Vec3.new(x, y, z)

GET Vec3.x

GET Vec3.y

GET Vec3.z

SET Vec3.x=(v)

SET Vec3.y=(v)

SET Vec3.z=(v)

GET Vec3.lengthSq

GET Vec3.length

GET Vec3.normalized

GET Vec3.toList

GET Vec3.data

GET Vec3.toString

FN Vec3.static zero

FN Vec3.static one

FN Vec3.static unitX

FN Vec3.static unitY

FN Vec3.static unitZ

FN Vec3.+(o)

FN Vec3.-(o)

FN Vec3.*(o)

FN Vec3./(o)

FN Vec3.-

FN Vec3.dot(o)

FN Vec3.distanceSq(o)

FN Vec3.distance(o)

FN Vec3.cross(o)

FN Vec3.static lerp(a, b, t)

FN Vec3.reflect(n)

FN Vec3.addInto(a, b)

FN Vec3.subInto(a, b)

FN Vec3.mulIntoScalar(a, s)

FN Vec3.copyFrom(v)

FN Vec3.approxEq(o)

FN Vec3.approxEq(o, eps)

FN Vec3.==(o)

FN Vec3.!=(o)

CL Vec4

NEW Vec4.new(x, y, z, w)

GET Vec4.x

GET Vec4.y

GET Vec4.z

GET Vec4.w

GET Vec4.r

GET Vec4.g

GET Vec4.b

GET Vec4.a

SET Vec4.x=(v)

SET Vec4.y=(v)

SET Vec4.z=(v)

SET Vec4.w=(v)

GET Vec4.lengthSq

GET Vec4.length

GET Vec4.xyz

GET Vec4.toList

GET Vec4.data

GET Vec4.toString

FN Vec4.static zero

FN Vec4.static one

FN Vec4.static rgba(r, g, b, a)

FN Vec4.+(o)

FN Vec4.-(o)

FN Vec4.*(o)

FN Vec4./(o)

FN Vec4.-

FN Vec4.dot(o)

FN Vec4.static lerp(a, b, t)

FN Vec4.approxEq(o)

FN Vec4.approxEq(o, eps)

FN Vec4.==(o)

FN Vec4.!=(o)

CL Mat4

NEW Mat4.new()

NEW Mat4.fromList(list)

GET Mat4.toList

GET Mat4.data

GET Mat4.transpose

GET Mat4.toString

FN Mat4.static zero

FN Mat4.static identity

FN Mat4.static translation(x, y, z)

FN Mat4.static scale(x, y, z)

FN Mat4.static rotationX(angle)

FN Mat4.static rotationY(angle)

FN Mat4.static rotationZ(angle)

FN Mat4.static perspective(fovY, aspect, near, far)

FN Mat4.static ortho(left, right, bottom, top, near, far)

FN Mat4.static lookAt(eye, target, up)

FN Mat4.at(r, c)

FN Mat4.set(r, c, v)

FN Mat4.*(o)

FN Mat4.setRaw_(i, v)

FN Mat4.transformPoint(v)

FN Mat4.transformDir(v)

FN Mat4.transformVec4(v)

FN Mat4.approxEq(other)

FN Mat4.approxEq(other, eps)

CL Quat

NEW Quat.new(w, x, y, z)

GET Quat.w

GET Quat.x

GET Quat.y

GET Quat.z

GET Quat.lengthSq

GET Quat.length

GET Quat.normalized

GET Quat.conjugate

GET Quat.toMat4

GET Quat.data

GET Quat.toString

FN Quat.static identity

FN Quat.static fromAxisAngle(axis, angle)

FN Quat.static fromEuler(yaw, pitch, roll)

FN Quat.*(o)

FN Quat.dot(o)

FN Quat.static slerp(a, b, t)

FN Quat.rotateVec3(v)

FN Quat.approxEq(o)

FN Quat.approxEq(o, eps)

FN Quat.==(o)

FN Quat.!=(o)