NanosMath
A table containing useful and aux Math functions.
๐ฟStatic Class
This is a Static Class. Access it's methods directly with
.
. It's not possible to spawn new instances.๐Open Source
This library implementation is Open Sourced on GitHub!
๐งโ๐ปAPI Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!
๐ย Examplesโ
(NanosMath.ClampAxis) Clamping an angle
local axis = NanosMath.ClampAxis(720)
(NanosMath.FInterpTo) Interpolating a number until it reaches 100 with speed 3
local my_value = 0
Client.Subscribe("Tick", function(delta_time)
my_value = NanosMath.FInterpTo(my_value, 100, delta_time, 3)
end)
(NanosMath.VInterpTo) Interpolating a Vector until it reaches Vector(1000, 200, 100) with speed 5
local my_value = Vector(0, 0, 0)
Client.Subscribe("Tick", function(delta_time)
my_value = NanosMath.VInterpTo(my_value, Vector(1000, 200, 100), delta_time, 5)
end)
๐ฟย Static Functionsโ
Returns | Name | Description | |
---|---|---|---|
number | Round | Rounds a number | |
number | Clamp | Clamps a number | |
number | ClampAxis | Clamps an angle to the range of [0, 360] | |
number | NormalizeAxis | Clamps an angle to the range of [-180, 180] | |
Vector, Rotator | RelativeTo | Calculates the location and rotation relative to an actor | |
Vector, Rotator | LocalToWorld | Converts a local location and rotation to world coordinates based on an actor's transform | |
float | RandomFloat | Returns a random float value | |
number | FInterpTo | Interpolate number from Current to Target | |
Rotator | RInterpTo | Interpolate Rotator from Current to Target | |
Rotator | RInterpConstantTo | Interpolate Rotator from Current to Target with a constant step | |
Vector | VInterpTo | Interpolate Vector from Current to Target | |
Vector | VInterpConstantTo | Interpolate Vector from Current to Target with a constant step |
Round
Rounds a number
โ Returns number (the rounded number).
local ret = NanosMath.Round(value)
Type | Parameter | Default | Description |
---|---|---|---|
number | value | Required parameter | The number to be rounded |
Clamp
Clamps a number
โ Returns number (the number clamped).
local ret = NanosMath.Clamp(value, min, max)
Type | Parameter | Default | Description |
---|---|---|---|
number | value | Required parameter | The number to be clamped |
number | min | Required parameter | The min value |
number | max | Required parameter | The max value |
ClampAxis
Clamps an angle to the range of [0, 360]
โ Returns number (the number clamped).
local ret = NanosMath.ClampAxis(value)
Type | Parameter | Default | Description |
---|---|---|---|
number | value | Required parameter | The number to be clamped |
NanosMath.ClampAxis Examples
Clamping an angle
local axis = NanosMath.ClampAxis(720)
NormalizeAxis
Clamps an angle to the range of [-180, 180]
โ Returns number (the number clamped).
local ret = NanosMath.NormalizeAxis(value)
Type | Parameter | Default | Description |
---|---|---|---|
number | value | Required parameter | The number to be clamped |
RelativeTo
Calculates the location and rotation relative to an actor
โ Returns Vector, Rotator (the location relative to the actor, the rotation relative to the actor).
local ret_01, ret_02 = NanosMath.RelativeTo(location, rotation, actor)
Type | Parameter | Default | Description |
---|---|---|---|
Vector | location | Required parameter | The location of the new system |
Rotator | rotation | Required parameter | The rotation of the new system |
Base Actor | actor | Required parameter | The actor to be translated to the new system |
LocalToWorld
Takes a local position and rotation relative to an actor, applies the actor's location, rotation, and scale to compute world-space location and rotation.
โ Returns Vector, Rotator (the location in world coordinates, the rotation in world coordinates).
local ret_01, ret_02 = NanosMath.LocalToWorld(local_location, local_rotation, actor)
Type | Parameter | Default | Description |
---|---|---|---|
Vector | local_location | Required parameter | The local location to convert |
Rotator | local_rotation | Required parameter | The local rotation to convert |
Base Actor | actor | Required parameter | The actor whose transform defines the local space |
RandomFloat
Returns a random float value
โ Returns float (the random value).
local ret = NanosMath.RandomFloat(min, max)
Type | Parameter | Default | Description |
---|---|---|---|
float | min | Required parameter | Minimum value |
float | max | Required parameter | Maximum value |
FInterpTo
Interpolate number from Current to Target
โ Returns number.
local ret = NanosMath.FInterpTo(current, target, delta_time, interp_speed)
Type | Parameter | Default | Description |
---|---|---|---|
number | current | Required parameter | No description provided |
number | target | Required parameter | No description provided |
number | delta_time | Required parameter | No description provided |
number | interp_speed | Required parameter | No description provided |
NanosMath.FInterpTo Examples
Interpolating a number until it reaches 100 with speed 3
local my_value = 0
Client.Subscribe("Tick", function(delta_time)
my_value = NanosMath.FInterpTo(my_value, 100, delta_time, 3)
end)
RInterpTo
Interpolate Rotator from Current to Target
โ Returns Rotator.
local ret = NanosMath.RInterpTo(current, target, delta_time, interp_speed)
Type | Parameter | Default | Description |
---|---|---|---|
Rotator | current | Required parameter | No description provided |
Rotator | target | Required parameter | No description provided |
number | delta_time | Required parameter | No description provided |
number | interp_speed | Required parameter | No description provided |
RInterpConstantTo
Interpolate Rotator from Current to Target with a constant step
โ Returns Rotator.
local ret = NanosMath.RInterpConstantTo(current, target, delta_time, interp_speed)
Type | Parameter | Default | Description |
---|---|---|---|
Rotator | current | Required parameter | No description provided |
Rotator | target | Required parameter | No description provided |
number | delta_time | Required parameter | No description provided |
number | interp_speed | Required parameter | No description provided |
VInterpTo
Interpolate Vector from Current to Target
โ Returns Vector.
local ret = NanosMath.VInterpTo(current, target, delta_time, interp_speed)
Type | Parameter | Default | Description |
---|---|---|---|
Vector | current | Required parameter | No description provided |
Vector | target | Required parameter | No description provided |
number | delta_time | Required parameter | No description provided |
number | interp_speed | Required parameter | No description provided |
NanosMath.VInterpTo Examples
Interpolating a Vector until it reaches Vector(1000, 200, 100) with speed 5
local my_value = Vector(0, 0, 0)
Client.Subscribe("Tick", function(delta_time)
my_value = NanosMath.VInterpTo(my_value, Vector(1000, 200, 100), delta_time, 5)
end)
VInterpConstantTo
Interpolate Vector from Current to Target with a constant step
โ Returns Vector.
local ret = NanosMath.VInterpConstantTo(current, target, delta_time, interp_speed)