Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • MathBitByBit

Index

Constructors

constructor

Methods

abs

  • Returns the absolute value (removes negative sign, always positive or zero). Example: |-5| → 5, |3| → 3, |0| → 0

    group

    basics

    shortname

    abs

    drawable

    false

    Parameters

    Returns number

    number

acos

  • Calculates the arccosine (inverse cosine) in radians, returns angle whose cosine is the input. Example: acos(1) → 0, acos(0) → π/2 (1.57), acos(-1) → π (3.14)

    group

    basics

    shortname

    acos

    drawable

    false

    Parameters

    Returns number

    number

add

  • Adds two numbers together. Example: 5 + 3 → 8, -2 + 7 → 5

    group

    basics

    shortname

    add

    drawable

    false

    Parameters

    Returns number

    number

asin

  • Calculates the arcsine (inverse sine) in radians, returns angle whose sine is the input. Example: asin(0) → 0, asin(1) → π/2 (1.57), asin(0.5) → π/6 (0.524)

    group

    basics

    shortname

    asin

    drawable

    false

    Parameters

    Returns number

    number

atan

  • Calculates the arctangent (inverse tangent) in radians, returns angle whose tangent is the input. Example: atan(0) → 0, atan(1) → π/4 (~0.785), atan(-1) → -π/4

    group

    basics

    shortname

    atan

    drawable

    false

    Parameters

    Returns number

    number

ceil

  • Rounds a number up to the nearest integer (toward positive infinity). Example: 3.2 → 4, -2.8 → -2, 5 → 5

    group

    basics

    shortname

    ceil

    drawable

    false

    Parameters

    Returns number

    number

clamp

  • Constrains a value between a minimum and maximum value. Example: clamp(5, 0, 3) returns 3, clamp(-1, 0, 3) returns 0, clamp(1.5, 0, 3) returns 1.5

    group

    operations

    shortname

    clamp

    drawable

    false

    Parameters

    • inputs: ClampDto

      a number, min and max values

    Returns number

    number clamped between min and max

cos

  • Calculates the cosine of an angle in radians. Example: cos(0) → 1, cos(π/2) → ~0, cos(π) → -1

    group

    basics

    shortname

    cos

    drawable

    false

    Parameters

    Returns number

    number

degToRad

  • Converts an angle from degrees to radians. Example: 180° → π (3.14159), 90° → π/2 (1.5708), 360° → 2π

    group

    basics

    shortname

    deg to rad

    drawable

    false

    Parameters

    Returns number

    number

divide

  • Divides the first number by the second. Example: 10 ÷ 2 → 5, 7 ÷ 2 → 3.5

    group

    basics

    shortname

    divide

    drawable

    false

    Parameters

    Returns number

    number

ease

  • Applies an easing function to interpolate smoothly between min and max values. Example: x=0.5 from [0,100] with easeInQuad → applies quadratic acceleration curve Useful for smooth animations with various acceleration/deceleration curves.

    group

    operations

    shortname

    ease

    drawable

    false

    Parameters

    • inputs: EaseDto

      a number, min and max values, and ease type

    Returns number

    number

exp

  • Calculates e raised to the power of the input (exponential function). Example: e⁰ → 1, e¹ → ~2.718, e² → ~7.389

    group

    basics

    shortname

    exp

    drawable

    false

    Parameters

    Returns number

    number

floor

  • Rounds a number down to the nearest integer (toward negative infinity). Example: 3.7 → 3, -2.3 → -3, 5 → 5

    group

    basics

    shortname

    floor

    drawable

    false

    Parameters

    Returns number

    number

fract

  • Returns the fractional part of a number (removes integer part, keeps decimals). Example: 3.14 → 0.14, 5.9 → 0.9, -2.3 → 0.7 Useful for wrapping values and creating repeating patterns.

    group

    operations

    shortname

    fract

    drawable

    false

    Parameters

    Returns number

    fractional part (always positive)

inverseLerp

  • Calculates the interpolation parameter t for a value between start and end (reverse of lerp). Example: Value 5 in range [0,10] → t=0.5, Value 2.5 in range [0,10] → t=0.25 Returns what t value would produce the given value in a lerp. Useful for finding relative position.

    group

    operations

    shortname

    inverse lerp

    drawable

    false

    Parameters

    • inputs: InverseLerpDto

      start value, end value, and the value to find t for

    Returns number

    interpolation parameter (typically 0-1)

lerp

  • Linear interpolation between two values using parameter t (0 to 1). Example: From 0 to 100 at t=0.5 → 50, From 10 to 20 at t=0.25 → 12.5 When t=0 returns start, when t=1 returns end. Useful for smooth transitions.

    group

    operations

    shortname

    lerp

    drawable

    false

    Parameters

    • inputs: LerpDto

      start value, end value, and interpolation parameter t

    Returns number

    interpolated value

ln

  • Calculates the natural logarithm (base e) of a number. Example: ln(2.718) → ~1, ln(7.389) → ~2, ln(1) → 0

    group

    basics

    shortname

    ln

    drawable

    false

    Parameters

    Returns number

    number

log10

  • Calculates the base 10 logarithm of a number. Example: log₁₀(100) → 2, log₁₀(1000) → 3, log₁₀(10) → 1

    group

    basics

    shortname

    log10

    drawable

    false

    Parameters

    Returns number

    number

modulus

  • Calculates the remainder after division (modulus operation). Example: 10 % 3 → 1, 17 % 5 → 2

    group

    operations

    shortname

    modulus

    drawable

    false

    Parameters

    Returns number

    Result of modulus operation

moveTowards

  • Moves a value toward a target by a maximum delta amount (never overshooting). Example: From 0 toward 10 by max 3 → 3, From 8 toward 10 by max 3 → 10 (reached) Useful for smooth movement with maximum speed limits.

    group

    operations

    shortname

    move towards

    drawable

    false

    Parameters

    • inputs: MoveTowardsDto

      current value, target value, and maximum delta

    Returns number

    new value moved toward target

multiply

  • Multiplies two numbers together. Example: 5 × 3 → 15, -2 × 4 → -8

    group

    basics

    shortname

    multiply

    drawable

    false

    Parameters

    Returns number

    number

negate

  • Negates a number (flips its sign: positive becomes negative, negative becomes positive). Example: 5 → -5, -3 → 3, 0 → 0

    group

    basics

    shortname

    negate

    drawable

    false

    Parameters

    Returns number

    number

number

  • Creates and returns a number value (pass-through for number input). Example: Input 42 → 42, Input 3.14 → 3.14

    group

    create

    shortname

    number

    drawable

    false

    Parameters

    Returns number

    number

oneNrOperation

  • Performs mathematical operations on a single number (absolute, negate, sqrt, trig functions, logarithms, etc.). Example: sqrt(5) → 2.236, abs(-3) → 3, sin(π/2) → 1

    group

    operations

    shortname

    one number

    drawable

    false

    Parameters

    Returns number

    Result of math operation

pi

  • pi(): number
  • Returns the mathematical constant π (pi) ≈ 3.14159. Example: Outputs 3.141592653589793

    group

    generate

    shortname

    π

    drawable

    false

    Returns number

    A number PI

pingPong

  • Creates a ping-pong (back-and-forth) effect that bounces a value between 0 and length. The value goes from 0→length, then back length→0, repeating this cycle. Example: With length=1: t=0→0, t=0.5→0.5, t=1→1 (peak), t=1.5→0.5, t=2→0, t=2.5→0.5 (repeats) Useful for creating bouncing animations like a ball or oscillating motion.

    group

    operations

    shortname

    ping pong

    drawable

    false

    Parameters

    Returns number

    value bouncing between 0 and length

power

  • Raises the first number to the power of the second (exponentiation). Example: 2³ → 8, 5² → 25, 10⁻¹ → 0.1

    group

    basics

    shortname

    power

    drawable

    false

    Parameters

    Returns number

    number

radToDeg

  • Converts an angle from radians to degrees. Example: π → 180°, π/2 → 90°, 2π → 360°

    group

    basics

    shortname

    rad to deg

    drawable

    false

    Parameters

    Returns number

    number

random

  • random(): number
  • Generates a random decimal number between 0 (inclusive) and 1 (exclusive). Example: Outputs like 0.342, 0.891, or any value in [0, 1)

    group

    generate

    shortname

    random 0 - 1

    drawable

    false

    Returns number

    A random number between 0 and 1

randomNumber

  • Generates a random number within a specified range (low to high). Example: Range [0, 10] → outputs like 3.7, 8.2, or any value between 0 and 10

    group

    generate

    shortname

    random number

    drawable

    false

    Parameters

    Returns number

    A random number

randomNumbers

  • Generates multiple random numbers within a specified range. Example: Range [0, 10] with 3 items → [2.5, 7.1, 4.8]

    group

    generate

    shortname

    random numbers

    drawable

    false

    Parameters

    Returns number[]

    A list of random numbers

remap

  • Maps a number from one range to another range proportionally. Example: 5 from [0,10] to [0,100] → 50, 0.5 from [0,1] to [-10,10] → 0

    group

    operations

    shortname

    remap

    drawable

    false

    Parameters

    Returns number

    Result of mapping

round

  • Rounds a number to the nearest integer. Example: 3.7 → 4, 2.3 → 2, 5.5 → 6

    group

    basics

    shortname

    round

    drawable

    false

    Parameters

    Returns number

    number

roundAndRemoveTrailingZeros

  • Rounds a number to specified decimal places and removes trailing zeros. Example: 1.32156 with 3 decimals returns 1.322, but 1.320000001 returns 1.32, and 1.000 returns 1

    group

    operations

    shortname

    round trim zeros

    drawable

    false

    Parameters

    Returns number

    Result of rounding as a number without trailing zeros

roundToDecimals

  • Rounds a number to specified decimal places. Example: 1.32156 with 3 decimals returns 1.322

    group

    operations

    shortname

    round to decimals

    drawable

    false

    Parameters

    Returns number

    Result of rounding

sign

  • Returns the sign of a number: -1 for negative, 0 for zero, 1 for positive. Example: -5 → -1, 0 → 0, 3.14 → 1 Useful for determining direction or polarity.

    group

    operations

    shortname

    sign

    drawable

    false

    Parameters

    Returns number

    -1, 0, or 1

sin

  • Calculates the sine of an angle in radians. Example: sin(0) → 0, sin(π/2) → 1, sin(π) → ~0

    group

    basics

    shortname

    sin

    drawable

    false

    Parameters

    Returns number

    number

smoothstep

  • Hermite interpolation with smooth acceleration and deceleration (smoother than linear lerp). Example: x=0 → 0, x=0.5 → 0.5, x=1 → 1 (but with smooth S-curve in between) Input is automatically clamped to [0,1]. Output eases in and out smoothly. Great for animations.

    group

    operations

    shortname

    smoothstep

    drawable

    false

    Parameters

    Returns number

    smoothly interpolated value

sqrt

  • Calculates the square root of a number. Example: √9 → 3, √2 → 1.414, √16 → 4

    group

    basics

    shortname

    sqrt

    drawable

    false

    Parameters

    Returns number

    number

subtract

  • Subtracts the second number from the first. Example: 10 - 3 → 7, 5 - 8 → -3

    group

    basics

    shortname

    subtract

    drawable

    false

    Parameters

    Returns number

    number

tan

  • Calculates the tangent of an angle in radians. Example: tan(0) → 0, tan(π/4) → ~1, tan(π/2) → infinity

    group

    basics

    shortname

    tan

    drawable

    false

    Parameters

    Returns number

    number

tenPow

  • Raises 10 to the power of the input number. Example: 10² → 100, 10³ → 1000, 10⁻¹ → 0.1

    group

    basics

    shortname

    ten pow

    drawable

    false

    Parameters

    Returns number

    number

toFixed

  • Formats a number as a string with a fixed number of decimal places (always shows trailing zeros). Example: 3.14159 with 2 decimals → '3.14', 5 with 3 decimals → '5.000'

    group

    operations

    shortname

    to fixed

    drawable

    false

    Parameters

    • inputs: ToFixedDto

      a number to be rounded to decimal places

    Returns string

    number

twoNrOperation

  • Performs basic arithmetic operations on two numbers (add, subtract, multiply, divide, power, modulus). Example: 5 + 3 → 8, 10 % 3 → 1, 2 ^ 3 → 8

    group

    operations

    shortname

    two numbers

    drawable

    false

    Parameters

    Returns number

    Result of math operation action

wrap

  • Wraps a number within a specified range (creates repeating cycle). Example: 1.5 in range [0,1) → 0.5, -0.3 in range [0,1) → 0.7, 370° in range [0,360) → 10° Useful for angles, UVs, or any repeating domain. Like modulo but handles negatives properly.

    group

    operations

    shortname

    wrap

    drawable

    false

    Parameters

    • inputs: WrapDto

      a number, min and max values

    Returns number

    wrapped value within range

Generated using TypeDoc