Math

All 143 raymath functions as idiomatic Iron methods on Vector2/3/4, Matrix, Quaternion + scalar helpers.

Math reference

All 143 raymath functions bound as idiomatic Iron methods on Vector2 / Vector3 / Vector4, Matrix, Quaternion, plus RMath.* scalar helpers.

Scalars

RMath.lerp(start, end, amount: Float32) -> Float32

Category: Scalars · raylib: Lerp

Linear interpolation: start + (end - start) * amount.

val mid = RMath.lerp(Float32(0.0), Float32(10.0), Float32(0.5))

raylib cheatsheet · Iron source · Test usage

RMath.normalize(value, start, end: Float32) -> Float32

Category: Scalars · raylib: Normalize

Inverse lerp — map value in [start, end] to [0, 1].

val t = RMath.normalize(x, Float32(0.0), Float32(10.0))

raylib cheatsheet · Iron source · Test usage

RMath.wrap(value, min, max: Float32) -> Float32 / remap(value, in_start, in_end, out_start, out_end) / float_equals(x, y)

Category: Scalars · raylib: Wrap / Remap / FloatEquals

Wrap around a range; remap between ranges; epsilon-aware equality.

val w = RMath.wrap(angle, Float32(-3.14159), Float32(3.14159))

raylib cheatsheet · Iron source · Test usage

Vector2

Vector2.add / subtract / multiply / divide(v, other) -> Vector2

Category: Vector2 · raylib: Vector2Add / Subtract / Multiply / Divide

Component-wise arithmetic.

val sum = Vector2.add(a, b)

raylib cheatsheet · Iron source · Test usage

Vector2.add_value / subtract_value(v, scalar: Float32) -> Vector2

Category: Vector2 · raylib: Vector2AddValue / SubtractValue

Scalar broadcast add/subtract.

val shifted = Vector2.add_value(v, Float32(1.0))

raylib cheatsheet · Iron source · Test usage

Vector2.scale(v, scale: Float32) / negate(v) / invert(v) -> Vector2

Category: Vector2 · raylib: Vector2Scale / Negate / Invert

Scalar multiply, component negate, reciprocal.

val s = Vector2.scale(v, Float32(2.0))

raylib cheatsheet · Iron source · Test usage

Vector2.length(v) / length_sqr(v) -> Float32

Category: Vector2 · raylib: Vector2Length / LengthSqr

Euclidean magnitude + squared magnitude (cheaper for comparisons).

val len = Vector2.length(v)

raylib cheatsheet · Iron source · Test usage

Vector2.dot_product(v, other) / distance(v, other) / distance_sqr(v, other) -> Float32

Category: Vector2 · raylib: Vector2DotProduct / Distance / DistanceSqr

Dot product, Euclidean distance between points.

val d = Vector2.dot_product(a, b)

raylib cheatsheet · Iron source · Test usage

Vector2.angle(v, other) / line_angle(start, end) -> Float32

Category: Vector2 · raylib: Vector2Angle / LineAngle

Angle between two vectors; angle of a line (radians).

val a = Vector2.angle(v1, v2)

raylib cheatsheet · Iron source · Test usage

Vector2.normalize(v) / transform(v, mat: Matrix) -> Vector2

Category: Vector2 · raylib: Vector2Normalize / Transform

Unit-length version; affine-transform a Vector2 by a Matrix.

val unit = Vector2.normalize(direction)

raylib cheatsheet · Iron source · Test usage

Vector2.lerp(v, other, amount) / move_towards(v, target, max_distance) / reflect(v, normal)

Category: Vector2 · raylib: Vector2Lerp / MoveTowards / Reflect

Linear interpolate; step toward target with distance cap; bounce vector off a normal.

val mid = Vector2.lerp(a, b, Float32(0.5))

raylib cheatsheet · Iron source · Test usage

Vector2.min / max / clamp(v, min, max: Vector2) / clamp_value(v, min, max: Float32) / equals(v, other) / refract(v, n, r)

Category: Vector2 · raylib: Vector2Min / Max / Clamp / ClampValue / Equals / Refract

Component-wise min/max/clamp, scalar-range clamp, epsilon equals, Snell-law refraction.

val clamped = Vector2.clamp(v, Vector2.zero(), Vector2.one())

raylib cheatsheet · Iron source · Test usage

Vector3

Vector3.add / subtract / multiply / divide(v, other) -> Vector3

Category: Vector3 · raylib: Vector3Add / Subtract / Multiply / Divide

Component-wise arithmetic.

val sum = Vector3.add(a, b)

raylib cheatsheet · Iron source · Test usage

Vector3.add_value / subtract_value(v, scalar) / scale(v, scalar) / negate / invert

Category: Vector3 · raylib: Vector3AddValue / SubtractValue / Scale / Negate / Invert

Scalar ops.

val s = Vector3.scale(v, Float32(2.0))

raylib cheatsheet · Iron source · Test usage

Vector3.cross_product(v, other) / perpendicular(v) -> Vector3

Category: Vector3 · raylib: Vector3CrossProduct / Perpendicular

Cross product; arbitrary perpendicular.

val n = Vector3.cross_product(u, v)

raylib cheatsheet · Iron source · Test usage

Vector3.length(v) / length_sqr(v) / distance(v, other) / distance_sqr(v, other) / dot_product(v, other) -> Float32

Category: Vector3 · raylib: Vector3Length / LengthSqr / Distance / DistanceSqr / DotProduct

Metric scalars.

val d = Vector3.distance(player, enemy)

raylib cheatsheet · Iron source · Test usage

Vector3.normalize(v) / project(v, other) / reject(v, other) -> Vector3

Category: Vector3 · raylib: Vector3Normalize / Project / Reject

Unit vector; projection onto line; orthogonal-component rejection.

val unit = Vector3.normalize(dir)

raylib cheatsheet · Iron source · Test usage

Vector3.ortho_normalize(v, other) -> (Vector3, Vector3)

Category: Vector3 · raylib: Vector3OrthoNormalize

Gram-Schmidt orthonormalization of two vectors — returns mutually-perpendicular unit vectors.

val (u, v) = Vector3.ortho_normalize(a, b)

raylib cheatsheet · Iron source · Test usage

Vector3.transform(v, mat: Matrix) / rotate_by_quaternion(v, q: Quaternion) / rotate_by_axis_angle(v, axis, angle)

Category: Vector3 · raylib: Vector3Transform / RotateByQuaternion / RotateByAxisAngle

Affine-transform by Matrix; rotate by quaternion or axis-angle.

val r = Vector3.rotate_by_axis_angle(forward, up, Float32(0.1))

raylib cheatsheet · Iron source · Test usage

Vector3.lerp(v, other, amount) / move_towards(v, target, max_distance) / cubic_hermite(v1, tangent1, v2, tangent2, t) / reflect(v, normal) / refract(v, n, r)

Category: Vector3 · raylib: Vector3Lerp / MoveTowards / CubicHermite / Reflect / Refract

Interpolation family.

val mid = Vector3.lerp(a, b, Float32(0.5))

raylib cheatsheet · Iron source · Test usage

Vector3.min / max / clamp / clamp_value / equals / barycenter / unproject

Category: Vector3 · raylib: Vector3Min / Max / Clamp / ClampValue / Equals / Barycenter / Unproject

Component min/max/clamp; barycentric coords in triangle; unproject from screen back to world.

val bary = Vector3.barycenter(p, a, b, c)

raylib cheatsheet · Iron source · Test usage

Vector4

Vector4.add / subtract / multiply / divide / scale / negate

Category: Vector4 · raylib: Vector4Add / Subtract / Multiply / Divide / Scale / Negate

Component-wise arithmetic.

val s = Vector4.scale(v, Float32(0.5))

raylib cheatsheet · Iron source · Test usage

Vector4.normalize / min / max / lerp / move_towards / invert / equals

Category: Vector4 · raylib: Vector4Normalize / Min / Max / Lerp / MoveTowards / Invert / Equals

Unit vector + clamp family + interpolation.

val unit = Vector4.normalize(v)

raylib cheatsheet · Iron source · Test usage

Matrix

Matrix.add / subtract / multiply(m, other) -> Matrix

Category: Matrix · raylib: MatrixAdd / Subtract / Multiply

Element-wise add/subtract, matrix-matrix multiply (composition).

val mvp = Matrix.multiply(view, proj)

raylib cheatsheet · Iron source · Test usage

Matrix.translate(x, y, z: Float32) / scale(x, y, z) -> Matrix

Category: Matrix · raylib: MatrixTranslate / Scale

Build translation / scale matrices.

val t = Matrix.translate(Float32(1.0), Float32(0.0), Float32(0.0))

raylib cheatsheet · Iron source · Test usage

Matrix.rotate(axis: Vector3, angle: Float32) / rotate_x / rotate_y / rotate_z(angle) / rotate_xyz(angle: Vector3) / rotate_zyx(angle)

Category: Matrix · raylib: MatrixRotate / RotateX / Y / Z / XYZ / ZYX

Rotation matrices.

val r = Matrix.rotate_y(Float32(0.5))

raylib cheatsheet · Iron source · Test usage

Matrix.frustum(left, right, bottom, top, near, far) / perspective(fovy, aspect, near, far) / ortho(left, right, bottom, top, near, far)

Category: Matrix · raylib: MatrixFrustum / Perspective / Ortho

Projection matrices — frustum, perspective, orthographic.

val proj = Matrix.perspective(Float32(45.0), Float32(1.333), Float32(0.1), Float32(1000.0))

raylib cheatsheet · Iron source · Test usage

Matrix.look_at(eye, target, up: Vector3) -> Matrix

Category: Matrix · raylib: MatrixLookAt

Right-handed view matrix pointing camera from eye toward target.

val view = Matrix.look_at(eye, Vector3.zero(), Vector3.of(0.0, 1.0, 0.0))

raylib cheatsheet · Iron source · Test usage

Matrix.to_float_v(m: Matrix) -> Float16 / Matrix.decompose(m) -> (Vector3, Quaternion, Vector3)

Category: Matrix · raylib: MatrixToFloatV / Decompose

Pack to 16-float buffer; decompose into translation, rotation, scale.

val (t, r, s) = Matrix.decompose(world)

raylib cheatsheet · Iron source · Test usage

Quaternion

Quaternion.add / subtract / multiply / divide / scale / add_value / subtract_value

Category: Quaternion · raylib: QuaternionAdd / Subtract / Multiply / Divide / Scale / AddValue / SubtractValue

Component-wise arithmetic + quaternion composition (multiply).

val combined = Quaternion.multiply(q1, q2)

raylib cheatsheet · Iron source · Test usage

Quaternion.length(q) -> Float32 / normalize(q) / invert(q) -> Quaternion

Category: Quaternion · raylib: QuaternionLength / Normalize / Invert

Magnitude / unit / conjugate.

val unit = Quaternion.normalize(q)

raylib cheatsheet · Iron source · Test usage

Quaternion.lerp(q, other, amount) / nlerp(q, other, amount) / slerp(q, other, amount) / cubic_hermite_spline(q1, out_tangent1, q2, in_tangent2, t)

Category: Quaternion · raylib: QuaternionLerp / Nlerp / Slerp / CubicHermiteSpline

Interpolation family — slerp is the classic spherical lerp for camera / bone interp.

val mid = Quaternion.slerp(q1, q2, Float32(0.5))

raylib cheatsheet · Iron source · Test usage

Quaternion.from_axis_angle(axis: Vector3, angle: Float32) -> Quaternion

Category: Quaternion · raylib: QuaternionFromAxisAngle

Build quaternion from axis-angle.

val q = Quaternion.from_axis_angle(Vector3.of(0.0, 1.0, 0.0), Float32(1.57))

raylib cheatsheet · Iron source · Test usage

Quaternion.from_euler(pitch, yaw, roll: Float32) -> Quaternion / to_euler(q) -> Vector3

Category: Quaternion · raylib: QuaternionFromEuler / ToEuler

Euler angle ↔ quaternion conversion.

val q = Quaternion.from_euler(Float32(0.1), Float32(0.2), Float32(0.3))

raylib cheatsheet · Iron source · Test usage

Quaternion.to_matrix(q) -> Matrix / from_matrix(mat: Matrix) -> Quaternion

Category: Quaternion · raylib: QuaternionToMatrix / FromMatrix

4x4 rotation matrix ↔ quaternion roundtrip.

val m = Quaternion.to_matrix(q)

raylib cheatsheet · Iron source · Test usage

Quaternion.from_vector3_to_vector3(from, to: Vector3) -> Quaternion

Category: Quaternion · raylib: QuaternionFromVector3ToVector3

Minimum-arc rotation from one vector to another.

val q = Quaternion.from_vector3_to_vector3(forward, target)

raylib cheatsheet · Iron source · Test usage

Quaternion.transform(q, mat: Matrix) / equals(q, other) -> Bool

Category: Quaternion · raylib: QuaternionTransform / Equals

Matrix-transform; epsilon-aware equality.

if Quaternion.equals(q1, q2) { }

raylib cheatsheet · Iron source · Test usage

Notes

Test coverage

Every method above is exercised in tests/manual/raymath_smoke.iron with reproducible numeric assertions covering normalized vectors, identity matrices, and axis-aligned rotations.

Float32 ABI

All scalar parameters are Float32 — byte-identical to raylib's C float at the FFI boundary. Int32 is used for indices/counts; Bool for predicates.

See also