Extended Math API

The Extended Math API supplies:

  • Double-precision scalar helpers

  • 2D vectors (vector2)

  • 3D vectors (vector3)

  • Quaternions (quaternion)

  • 4×4 matrices (matrix4x4)

  • Read/write helpers for interacting with raw memory values

All math types support operator overloading and can be used naturally in AngelScript expressions.


2. Constants

All constants are const double and available globally:

Name
Description

M_PI

Pi (3.14159…)

M_TAU

Tau (2π)

M_PI_2

π/2

M_PI_4

π/4

RAD2DEG

Convert radians → degrees

DEG2RAD

Convert degrees → radians

M_ZERO

0.0

M_ONE

1.0

M_EPSILON

Small epsilon (1e-6)


3. Scalar Math Functions

clamp(x, a, b) → double

Clamp x into range [a, b].

saturate(x) → double

Clamp x into [0,1].

sign(x) → int

Returns -1, 0, or 1.

round / round_up / round_down

fract(x)

Positive fractional part.

wrap(x, min, max)

Wrap value into interval like modulo.

lerp(a, b, t)

Linear interpolate.

inverse_lerp(a, b, v)

Returns t such that lerp(a,b,t) = v.

remap(a1, b1, a2, b2, v)

Map a value between ranges.

smoothstep(edge0, edge1, x)

Smoothed curve between two edges.

step(edge, x)

Binary step function.

is_nan(x)

Check for NaN.

is_inf(x)

Check for infinity.


4. vector2

Constructors

Operators

Methods

Memory Helpers


5. vector3

Constructors

Operators

Methods

Memory Helpers


6. quaternion

Constructors

Static

(Euler angles in degrees.)

Operators

Methods

Memory Helpers


7. matrix4x4

Constructor

Global Functions

Operators

Methods


8. Memory Helpers Summary

Every math type supports reading/writing data from a 64-bit address:

Read

  • readas_double(proc_t& in, addr) – read consecutive doubles

  • readas_float(proc_t& in, addr) – read consecutive floats

Write

  • writeas_double(proc_t& in, addr) – write consecutive doubles

  • writeas_float(proc_t& in, addr) – write consecutive floats


9. Random


10. Example Usage

Vector math

3D vector operations

Quaternion rotation

Matrix transform

Reading a position from memory

Writing back

Full API Test

Last updated