Skip to main content

Math

This package contains extended math functions.

Package Attribute Value
__singleton false
__domain shared

Functions

isInRange

Math.isInRange(
valuenumber,
minnumber,
maxnumber
) → boolean

Returns a boolean true if value is within bounds (inclusive).

mapRange

Math.mapRange(
inputBounds{
inputMinnumber,
inputMaxnumber
},
outputBounds{
outputMinnumber,
outputMaxnumber
}
) → (xnumber) → number

Returns a function with an input parameter, which when executed, returns an output for the given bounds.

Math.mapRange({ 0, 1 }, { 0, 100 })(0.5) -- 50
Show raw api
{
    "functions": [
        {
            "name": "isInRange",
            "desc": "Returns a boolean `true` if `value` is within bounds (inclusive).\t\t",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "min",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "max",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 21,
                "path": "src/essentials/Math.lua"
            }
        },
        {
            "name": "mapRange",
            "desc": "Returns a function with an input parameter, which when executed, returns an output for the given bounds.\n\n```lua\nMath.mapRange({ 0, 1 }, { 0, 100 })(0.5) -- 50\n```\n\t",
            "params": [
                {
                    "name": "inputBounds",
                    "desc": "",
                    "lua_type": "{ inputMin: number, inputMax: number }"
                },
                {
                    "name": "outputBounds",
                    "desc": "",
                    "lua_type": "{ outputMin: number, outputMax: number }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "(x: number) -> number"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 37,
                "path": "src/essentials/Math.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Math",
    "desc": "This package contains extended math functions.\n\n| Package Attribute | Value |\n| --- | --- |\n| __singleton | false |\n| __domain | shared |",
    "source": {
        "line": 57,
        "path": "src/essentials/Math.lua"
    }
}