opx_lib
Lib.Math
Last updated on
Clamp, round, interpolate and measure distances between points.
Pure. No permission. A point is { x, y, z }.
Lib.Math.Clamp
Holds a number inside a range.
Lib.Math.Clamp(value, low, high)Parameters
- value:
number - low:
number - high:
number
Returns
number
Lib.Math.Round
Rounds half away from zero.
Lib.Math.Round(value, places)Parameters
- value:
number - places?:
integer- Default:
0.
- Default:
Returns
number
Lib.Math.Round(2.345, 2) -- 2.35Lib.Math.Lerp
Linear interpolation.
Lib.Math.Lerp(from, to, amount)Parameters
- from:
number - to:
number - amount:
number- 0..1.
Returns
number
Lib.Math.Distance
The distance between two points.
Lib.Math.Distance(left, right)Parameters
- left:
table - right:
table
Returns
number?—nilwhen a point is not readable
Lib.Math.Distance2D
The distance between two points, ignoring height.
Lib.Math.Distance2D(left, right)Parameters
- left:
table - right:
table
Returns
number?
Lib.Math.Near
Whether two points are within radius, ignoring height.
Lib.Math.Near(left, right, radius)Parameters
- left:
table - right:
table - radius:
number
Returns
boolean
if Lib.Math.Near(here, shop, 3.0) then showPrompt() end