|
| | Module_REG (Math) |
| |
| | Math () |
| | Initializes RNG and math helpers.
|
| |
| | ~Math () override=default |
| | Releases module state; caller-owned Vec/Mat pointers are not freed.
|
| |
| Vec2 * | newVec2 (float x=0.f, float y=0.f) |
| | Allocates a Vec2. @ownership Caller deletes.
|
| |
| Vec3 * | newVec3 (float x=0.f, float y=0.f, float z=0.f) |
| | Allocates a Vec3. @ownership Caller deletes.
|
| |
| Mat4 * | newMat4 () |
| | Allocates an identity Mat4. @ownership Caller deletes.
|
| |
| Mat4 * | newMat4Translation (float x, float y, float z) |
| | Allocates a translation Mat4. @ownership Caller deletes.
|
| |
| Mat4 * | newMat4Scale (float sx, float sy, float sz) |
| | Allocates a scale Mat4. @ownership Caller deletes.
|
| |
| Mat4 * | newMat4RotationZ (float radians) |
| | Allocates a Z-rotation Mat4 (radians). @ownership Caller deletes.
|
| |
| float | clamp (float x, float lo, float hi) const |
| | Clamps x into [lo, hi].
|
| |
| float | lerp (float a, float b, float t) const |
| | Linear interpolation between a and b by t.
|
| |
| float | smoothstep (float edge0, float edge1, float x) const |
| | Hermite smoothstep between edge0 and edge1.
|
| |
| float | remap (float x, float inMin, float inMax, float outMin, float outMax) const |
| | Maps x from [inMin,inMax] into [outMin,outMax].
|
| |
| float | degToRad (float deg) const |
| | Degrees to radians.
|
| |
| float | radToDeg (float rad) const |
| | Radians to degrees.
|
| |
| float | sign (float x) const |
| | Sign of x (-1, 0, or 1).
|
| |
| float | fract (float x) const |
| | Fractional part of x.
|
| |
| float | approach (float current, float target, float maxDelta) const |
| | Moves current toward target by at most maxDelta.
|
| |
| float | wrap (float x, float lo, float hi) const |
| | Wraps x into [lo, hi).
|
| |
| float | pingPong (float t, float length) const |
| | Triangle-wave ping-pong of t over [0, length].
|
| |
| float | inverseLerp (float a, float b, float x) const |
| | Linear interpolation between a and b by t.
|
| |
| float | smootherstep (float edge0, float edge1, float x) const |
| | Ken Perlin smootherstep between edge0 and edge1.
|
| |
| float | bias (float t, float b) const |
| | Schlick bias/gain — shape [0,1] distributions (procgen falloff).
|
| |
| float | gain (float t, float g) const |
| | Schlick gain shaping of t in [0,1].
|
| |
| float | ease (float t, const std::string &kind) const |
| | Easing on [0,1]. kind: "linear"|"inQuad"|"outQuad"|"inOutQuad"|"inCubic"|"outCubic"|"inOutCubic"| "inSine"|"outSine"|"inOutSine"|"inExpo"|"outExpo"|"inOutExpo"
|
| |
| float | step (float edge, float x) const |
| | Heaviside step: 0 if x < edge else 1.
|
| |
| float | quantize (float x, float stepSize) const |
| | Quantizes x to multiples of stepSize.
|
| |
| float | snap (float x, float grid) const |
| | Snaps x to the nearest grid multiple.
|
| |
| float | length2 (float x, float y) const |
| | 2D vector length from components.
|
| |
| float | length3 (float x, float y, float z) const |
| | 3D vector length from components.
|
| |
| float | distance2 (float x1, float y1, float x2, float y2) const |
| | 2D distance between two points.
|
| |
| float | distance3 (float x1, float y1, float z1, float x2, float y2, float z2) const |
| | 3D distance between two points.
|
| |
| float | dot2 (float x1, float y1, float x2, float y2) const |
| | 2D dot product of two vectors.
|
| |
| float | dot3 (float x1, float y1, float z1, float x2, float y2, float z2) const |
| | 3D dot product of two vectors.
|
| |
| float | cross2 (float x1, float y1, float x2, float y2) const |
| | 2D cross product (scalar z-component).
|
| |
| float | angle2 (float x, float y) const |
| | Atan2 angle of (x,y) in radians.
|
| |
| float | angleBetween2 (float x1, float y1, float x2, float y2) const |
| | Signed angle from first vector to second.
|
| |
| float | lerpAngle (float a, float b, float t) const |
| | Shortest-path angle interpolation.
|
| |
| float | normalize2X (float x, float y) const |
| | X of the normalized 2D vector (zero-safe).
|
| |
| float | normalize2Y (float x, float y) const |
| | Y of the normalized 2D vector (zero-safe).
|
| |
| float | normalize3X (float x, float y, float z) const |
| | X of the normalized 3D vector (zero-safe).
|
| |
| float | normalize3Y (float x, float y, float z) const |
| | Y of the normalized 3D vector (zero-safe).
|
| |
| float | normalize3Z (float x, float y, float z) const |
| | Z of the normalized 3D vector (zero-safe).
|
| |
| Vec2 * | steeringSeek2 (float x, float y, float targetX, float targetY, float maxSpeed) const |
| | Creates a 2D seek velocity. @ownership owned @lifetime Caller deletes the result.
|
| |
| Vec3 * | steeringSeek3 (float x, float y, float z, float targetX, float targetY, float targetZ, float maxSpeed) const |
| | Creates a 3D seek velocity. @ownership owned @lifetime Caller deletes the result.
|
| |
| Vec2 * | steeringFlee2 (float x, float y, float targetX, float targetY, float maxSpeed) const |
| | Creates a 2D flee velocity. @ownership owned @lifetime Caller deletes the result.
|
| |
| Vec3 * | steeringFlee3 (float x, float y, float z, float targetX, float targetY, float targetZ, float maxSpeed) const |
| | Creates a 3D flee velocity. @ownership owned @lifetime Caller deletes the result.
|
| |
| Vec2 * | steeringArrive2 (float x, float y, float targetX, float targetY, float maxSpeed, float slowRadius, float stopRadius) const |
| | Creates a 2D arrive velocity. @ownership owned @lifetime Caller deletes the result.
|
| |
| Vec3 * | steeringArrive3 (float x, float y, float z, float targetX, float targetY, float targetZ, float maxSpeed, float slowRadius, float stopRadius) const |
| | Creates a 3D arrive velocity. @ownership owned @lifetime Caller deletes the result.
|
| |
| Vec2 * | steeringSeparation2 (float x, float y, const std::string &neighbors, float radius, float maxAcceleration) const |
| | Creates 2D separation acceleration from CSV. @ownership owned @lifetime Caller deletes the result.
|
| |
| Vec3 * | steeringSeparation3 (float x, float y, float z, const std::string &neighbors, float radius, float maxAcceleration) const |
| | Creates 3D separation acceleration from CSV. @ownership owned @lifetime Caller deletes the result.
|
| |
| int | steeringPathTarget2 (float x, float y, const std::string &points, int current, float tolerance) const |
| | Selects a 2D path point from CSV x:y points, or -1 for no valid points.
|
| |
| int | steeringPathTarget3 (float x, float y, float z, const std::string &points, int current, float tolerance) const |
| | Selects a 3D path point from CSV x:y:z points, or -1 for no valid points.
|
| |
| Vec2 * | steeringAvoid2 (float x, float y, float velocityX, float velocityY, float obstacleX, float obstacleY, float obstacleRadius, float lookAhead, float maxAcceleration) const |
| | Creates 2D avoidance acceleration. @ownership owned @lifetime Caller deletes the result.
|
| |
| Vec3 * | steeringAvoid3 (float x, float y, float z, float velocityX, float velocityY, float velocityZ, float obstacleX, float obstacleY, float obstacleZ, float obstacleRadius, float lookAhead, float maxAcceleration) const |
| | Creates 3D avoidance acceleration. @ownership owned @lifetime Caller deletes the result.
|
| |
| float | rotate2X (float x, float y, float radians) const |
| | Rotate (x,y) by radians around origin.
|
| |
| float | rotate2Y (float x, float y, float radians) const |
| | Y after rotating (x,y) by radians about the origin.
|
| |
| float | polarX (float radius, float radians) const |
| | X of polar (radius, radians).
|
| |
| float | polarY (float radius, float radians) const |
| | Y of polar (radius, radians).
|
| |
| float | cartesianRadius (float x, float y) const |
| | Length of (x,y).
|
| |
| float | cartesianAngle (float x, float y) const |
| | Atan2 angle of (x,y).
|
| |
| bool | pointInCircle (float px, float py, float cx, float cy, float radius) const |
| | True if point is inside or on the circle.
|
| |
| bool | pointInRect (float px, float py, float rx, float ry, float rw, float rh) const |
| | True if point is inside or on the axis-aligned rect.
|
| |
| bool | circlesOverlap (float x1, float y1, float r1, float x2, float y2, float r2) const |
| | True if two circles overlap.
|
| |
| bool | rectsOverlap (float x1, float y1, float w1, float h1, float x2, float y2, float w2, float h2) const |
| | True if two axis-aligned rects overlap.
|
| |
| bool | circleRectOverlap (float cx, float cy, float radius, float rx, float ry, float rw, float rh) const |
| | True if circle and axis-aligned rect overlap.
|
| |
| bool | segmentsIntersect (float ax, float ay, float bx, float by, float cx, float cy, float dx, float dy) const |
| | True if segments AB and CD intersect (including endpoints).
|
| |
| float | raycastCircle2 (float ox, float oy, float dx, float dy, float cx, float cy, float radius) const |
| | Ray vs circle. Hit point = (ox,oy) + t*(dx,dy). Returns t >= 0 on hit, else -1. Direction need not be unit; for a segment use dir = B-A and accept t in [0,1].
|
| |
| float | raycastRect2 (float ox, float oy, float dx, float dy, float rx, float ry, float rw, float rh) const |
| | Ray vs axis-aligned rect (x,y,w,h). Returns parametric t >= 0, else -1.
|
| |
| float | closestPointOnSegment2X (float px, float py, float ax, float ay, float bx, float by) const |
| | X of the closest point on segment AB to P.
|
| |
| float | closestPointOnSegment2Y (float px, float py, float ax, float ay, float bx, float by) const |
| | Y of the closest point on segment AB to P.
|
| |
| bool | pointInSphere (float px, float py, float pz, float cx, float cy, float cz, float radius) const |
| | True if point is inside or on the sphere.
|
| |
| bool | pointInBox (float px, float py, float pz, float minX, float minY, float minZ, float maxX, float maxY, float maxZ) const |
| | Inclusive AABB test against [min,max] on each axis.
|
| |
| bool | spheresOverlap (float x1, float y1, float z1, float r1, float x2, float y2, float z2, float r2) const |
| | True if two spheres overlap.
|
| |
| bool | boxesOverlap (float minAx, float minAy, float minAz, float maxAx, float maxAy, float maxAz, float minBx, float minBy, float minBz, float maxBx, float maxBy, float maxBz) const |
| | True if two AABBs overlap.
|
| |
| float | raycastSphere (float ox, float oy, float oz, float dx, float dy, float dz, float cx, float cy, float cz, float radius) const |
| | Ray vs sphere; parametric t >= 0 on hit, else -1.
|
| |
| float | raycastBox (float ox, float oy, float oz, float dx, float dy, float dz, float minX, float minY, float minZ, float maxX, float maxY, float maxZ) const |
| | Ray vs AABB; parametric t >= 0 on hit, else -1.
|
| |
| float | raycastPlane (float ox, float oy, float oz, float dx, float dy, float dz, float px, float py, float pz, float nx, float ny, float nz) const |
| | Ray vs infinite plane through (px,py,pz) with normal (nx,ny,nz). Returns parametric t, or -1 if parallel / behind ray origin.
|
| |
| float | closestPointOnSegment3X (float px, float py, float pz, float ax, float ay, float az, float bx, float by, float bz) const |
| | X of the closest point on segment AB to P.
|
| |
| float | closestPointOnSegment3Y (float px, float py, float pz, float ax, float ay, float az, float bx, float by, float bz) const |
| | Y of the closest point on segment AB to P.
|
| |
| float | closestPointOnSegment3Z (float px, float py, float pz, float ax, float ay, float az, float bx, float by, float bz) const |
| | Z of the closest point on segment AB to P.
|
| |
| float | bilinear (float v00, float v10, float v01, float v11, float u, float v) const |
| | Bilinear sample of 4 corners (v00,v10,v01,v11) with u,v in [0,1].
|
| |
| void | setRandomSeed (uint32_t seed) |
| | Sets the module RNG seed.
|
| |
| void | setRandomSeedFromTime () |
| | Seeds the RNG from the system clock.
|
| |
| uint32_t | getRandomSeed () const |
| | Current RNG seed value.
|
| |
| float | random () |
| | Uniform float in [0, 1).
|
| |
| float | randomRange (float min, float max) |
| | Uniform float in [min, max).
|
| |
| int | randomInt (int min, int maxInclusive) |
| | Uniform inclusive integer in [min, maxInclusive].
|
| |
| float | randomGaussian (float mean, float stddev) |
| | Box-Muller Gaussian (mean, stddev).
|
| |
| float | hash1 (float x) const |
| | Deterministic 1D hash mapped to [0,1].
|
| |
| float | hash2 (float x, float y) const |
| | Deterministic 2D hash mapped to [0,1].
|
| |
| float | hash3 (float x, float y, float z) const |
| | Deterministic 3D hash mapped to [0,1].
|
| |
| float | noise1 (float x) const |
| | Value noise in 1D, range [0,1].
|
| |
| float | noise2 (float x, float y) const |
| | Value noise in 2D, range [0,1].
|
| |
| float | noise3 (float x, float y, float z) const |
| | Value noise in 3D, range [0,1].
|
| |
| float | perlin2 (float x, float y) const |
| | Perlin noise in 2D, range [0,1].
|
| |
| float | perlin3 (float x, float y, float z) const |
| | Perlin noise in 3D, range [0,1].
|
| |
| float | fbm2 (float x, float y, int octaves=4, float lacunarity=2.f, float gain=0.5f) const |
| | Fractal Brownian Motion / ridged / turbulence. octaves >= 1; lacunarity ~2; gain/persistence ~0.5.
|
| |
| float | fbm3 (float x, float y, float z, int octaves=4, float lacunarity=2.f, float gain=0.5f) const |
| | 3D fractal Brownian motion.
|
| |
| float | ridged2 (float x, float y, int octaves=4, float lacunarity=2.f, float gain=0.5f) const |
| | 2D ridged multifractal noise.
|
| |
| float | ridged3 (float x, float y, float z, int octaves=4, float lacunarity=2.f, float gain=0.5f) const |
| | 3D ridged multifractal noise.
|
| |
| float | turbulence2 (float x, float y, int octaves=4, float lacunarity=2.f, float gain=0.5f) const |
| | 2D turbulence (absolute fBm).
|
| |
| float | voronoi2 (float x, float y) const |
| | Worley / Voronoi F1 distance in [0, ~1.5] (cell size 1). voronoiEdge2 = F2 - F1 (cell borders).
|
| |
| float | voronoiEdge2 (float x, float y) const |
| | 2D Worley F2-F1 edge distance.
|
| |
| float | warpNoise2 (float x, float y, float warpAmp=1.f) const |
| | Domain warp: sample noise at (x,y) + warpAmp * (noise-0.5). Useful for organic terrain / caves.
|
| |
| float | bezierQuadratic (float t, float p0, float p1, float p2) const |
| | 1D quadratic Bezier at t in [0,1].
|
| |
| float | bezierCubic (float t, float p0, float p1, float p2, float p3) const |
| | 1D cubic Bezier at t in [0,1].
|
| |
| float | bezierQuadratic2X (float t, float x0, float y0, float x1, float y1, float x2, float y2) const |
| | X of a 2D quadratic Bezier at t.
|
| |
| float | bezierQuadratic2Y (float t, float x0, float y0, float x1, float y1, float x2, float y2) const |
| | Y of a 2D quadratic Bezier at t.
|
| |
| float | bezierCubic2X (float t, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) const |
| | X of a 2D cubic Bezier at t.
|
| |
| float | bezierCubic2Y (float t, float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) const |
| | Y of a 2D cubic Bezier at t.
|
| |
| virtual | ~Module () |
| | Module.
|
| |
| virtual std::string | getName () const =0 |
| | Returns the name.
|
| |