• Scales vectors to ≤ 1 unit length where vectors that started with a length greater than max are clamped to length 1, and shorter vectors are scaled between 0 - 1 based on their original fraction of their length relative to max.

    Parameters

    • x: number

      x component of the vector

    • y: number

      y component of the vector

    • max: number

      the length of the vector to clamp to

    Returns {
        x: number;
        y: number;
    }

    the scaled vector as an object with x and y components.

    • x: number
    • y: number