Files
prosperon/docs/api/modules/math.md
John Alanbrook 83b798e365 Add Hugo website and rewrite docs to match current engine
New Hugo site in website/ with prosperon.dev theme (blue/gold/castle
aesthetic), docs sidebar navigation, and content pages. Rewrote all
doc files to align with the actual codebase: compositor+film2d
rendering, use() modules (no global prosperon object), Pit language,
script+JSON entity model. Added entities.md, front matter to all
70+ API docs, and updated API index for current module architecture.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:09:55 -06:00

2.8 KiB

title, type
title type
math docs

math

dot() function

Compute the dot product between two numeric arrays, returning a scalar. Extra elements are ignored.

project() function

Project one vector onto another, returning a new array of the same dimension.

rotate() function

Rotate a 2D point (or array of length 2) by the given angle (in turns) around an optional pivot.

midpoint() function

Compute the midpoint of two arrays of numbers. Only the first two entries are used if 2D is intended.

reflect() function

Reflect a vector across a plane normal. Both arguments must be numeric arrays.

distance() function

Compute the Euclidean distance between two numeric arrays of matching length.

direction() function

Compute the normalized direction vector from the first array to the second.

angle() function

Given a 2D vector, return its angle from the X-axis in radians or some chosen units.

norm() function

Return a normalized copy of the given numeric array. For 2D/3D/4D or arbitrary length.

angle_between() function

Compute the angle between two vectors (2D/3D/4D).

lerp() function

Linear interpolation between two numbers: lerp(a, b, t).

gcd() function

Compute the greatest common divisor of two integers.

lcm() function

Compute the least common multiple of two integers.

clamp() function

Clamp a number between low and high. clamp(value, low, high).

angledist() function

Compute the signed distance between two angles in 'turn' units, e.g. 0..1 range.

jitter() function

Apply a random +/- percentage noise to a number. Example: jitter(100, 0.05) -> ~95..105.

mean() function

Compute the arithmetic mean of an array of numbers.

sum() function

Sum all elements of an array of numbers.

sigma() function

Compute standard deviation of an array of numbers.

median() function

Compute the median of an array of numbers.

length() function

Return the length of a vector (i.e. sqrt of sum of squares).

from_to() function

Return an array of points from a start to an end, spaced out by a certain distance.

rand() function

Return a random float in [0,1).

randi() function

Return a random 32-bit integer.

srand() function

Seed the random number generator with the given integer, or with current time if none.

TAU number

deg2rad(deg) function

rad2deg(rad) function

turn2rad(x) function

rad2turn(x) function

turn2deg(x) function

deg2turn(x) function