Small World Engine API Reference - v0.46.1
    Preparing search index...

    Class MathUtils

    Utility class for mathematical operations and constants.

    Index

    Constructors

    Properties

    DEG2RAD: number = ...

    Constant to convert degrees to radians.

    HALF_PI: number = ...

    Mathematical constant PI / 2.

    PI: number = Math.PI

    Mathematical constant PI.

    QUARTER_PI: number = ...

    Mathematical constant PI / 4.

    RAD2DEG: number = ...

    Constant to convert radians to degrees.

    TWO_PI: number = ...

    Mathematical constant 2 * PI.

    Methods

    • Clamps a value between a minimum and maximum.

      Parameters

      • val: number

        The value to clamp.

      • min: number

        The minimum value.

      • max: number

        The maximum value.

      Returns number

      The clamped value.

    • Converts degrees to radians.

      Parameters

      • degrees: number

        The angle in degrees.

      Returns number

      The angle in radians.

    • Returns the cosine of the given angle in radians using a lookup table.

      Parameters

      • rad: number

        The angle in radians.

      Returns number

      The cosine of the angle.

    • Returns the sine of the given angle in radians using a lookup table.

      Parameters

      • rad: number

        The angle in radians.

      Returns number

      The sine of the angle.

    • Generates a unique identifier (UUID v4). Uses crypto.randomUUID() if available.

      Returns string

      A string representation of a UUID.

    • Initializes the sine and cosine lookup tables for fast lookup.

      Returns void

    • Converts radians to degrees.

      Parameters

      • radians: number

        The angle in radians.

      Returns number

      The angle in degrees.