Passer au contenu principal
Version: bleeding-edge 🩸

NanosMath

Une table contenant des fonctions Math utiles et auxiliaires.


🎒 Exemples​

(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)

🗿 Fonctions statiques​

ReturnsNameDescription
floatRoundRounds a number to the nearest value with the given decimal places
floatClampEffectue une opération "Clamp" (limite la valeur minimale et maximale) sur un nombre
floatClampAxisClamps an angle to the range of [0, 360]
floatNormalizeAxisClamps an angle to the range of [-180, 180]
Vector, RotatorRelativeToCalcule la position et la rotation par rapport à un acteur
Vector, RotatorLocalToWorldConverts a local location and rotation to world coordinates based on an actor's transform
floatRandomFloatReturns a random float value
floatFInterpToInterpoler le nombre de "Actuel" vers "Cible"
RotatorRInterpToInterpoler le Rotator de "Actuel" vers "Cible"
RotatorRInterpConstantToInterpoler le Rotator de "Actuel" vers "Cible" avec une évolution constante
VectorVInterpToInterpoler le Vector de "Actuel" vers "Cible"
VectorVInterpConstantToInterpoler le Vector de "Actuel" vers "Cible" avec une évolution constante

Optimal

Round​

Rounds a number to the nearest value with the given decimal places
local ret = NanosMath.Round(value, decimals?)

Parameters

TypeParameterDefaultDescription
floatvalue Required parameter The number to be rounded
integerdecimals?0
How many decimal places to keep

Returns

TypeDescription
floatthe rounded number

Optimal

Clamp​

Effectue une opération "Clamp" (limite la valeur minimale et maximale) sur un nombre
local ret = NanosMath.Clamp(value, min, max)

Parameters

TypeParameterDefaultDescription
floatvalue Required parameter The number to be clamped
floatmin Required parameter The min value
floatmax Required parameter The max value

Returns

TypeDescription
floatthe number clamped

Optimal

ClampAxis​

Clamps an angle to the range of [0, 360]
local ret = NanosMath.ClampAxis(value)

Parameters

TypeParameterDefaultDescription
floatvalue Required parameter The number to be clamped

Returns

TypeDescription
floatthe number clamped
NanosMath.ClampAxis Examples
Clamping an angle
local axis = NanosMath.ClampAxis(720)

Optimal

NormalizeAxis​

Clamps an angle to the range of [-180, 180]
local ret = NanosMath.NormalizeAxis(value)

Parameters

TypeParameterDefaultDescription
floatvalue Required parameter The number to be clamped

Returns

TypeDescription
floatthe number clamped

Optimal

RelativeTo​

Calcule la position et la rotation par rapport à un acteur
local ret_1, ret_2 = NanosMath.RelativeTo(location, rotation, actor)

Parameters

TypeParameterDefaultDescription
Vectorlocation Required parameter The location of the new system
Rotatorrotation Required parameter The rotation of the new system
Base Actoractor Required parameter The actor to be translated to the new system

Returns

TypeDescription
Vectorthe location relative to the actor
Rotatorthe rotation relative to the actor

Optimal

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.
local ret_1, ret_2 = NanosMath.LocalToWorld(local_location, local_rotation, actor)

Parameters

TypeParameterDefaultDescription
Vectorlocal_location Required parameter The local location to convert
Rotatorlocal_rotation Required parameter The local rotation to convert
Base Actoractor Required parameter The actor whose transform defines the local space

Returns

TypeDescription
Vectorthe location in world coordinates
Rotatorthe rotation in world coordinates

Optimal

RandomFloat​

Returns a random float value
local ret = NanosMath.RandomFloat(min, max)

Parameters

TypeParameterDefaultDescription
floatmin Required parameter Minimum value
floatmax Required parameter Maximum value

Returns

TypeDescription
floatthe random value

Optimal

FInterpTo​

Interpoler le nombre de "Actuel" vers "Cible"
local ret = NanosMath.FInterpTo(current, target, delta_time, interp_speed)

Parameters

TypeParameterDefaultDescription
floatcurrent Required parameter The current value
floattarget Required parameter The target value
floatdelta_time Required parameter Time since the last call, usually the Tick delta time
floatinterp_speed Required parameter Interpolation speed, 0 jumps straight to the target

Returns

TypeDescription
floatThe interpolated value
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)

Optimal

RInterpTo​

Interpoler le Rotator de "Actuel" vers "Cible"
local ret = NanosMath.RInterpTo(current, target, delta_time, interp_speed)

Parameters

TypeParameterDefaultDescription
Rotatorcurrent Required parameter The current value
Rotatortarget Required parameter The target value
floatdelta_time Required parameter Time since the last call, usually the Tick delta time
floatinterp_speed Required parameter Interpolation speed, 0 jumps straight to the target

Returns

TypeDescription
RotatorThe interpolated Rotator

Optimal

RInterpConstantTo​

Interpoler le Rotator de "Actuel" vers "Cible" avec une évolution constante
local ret = NanosMath.RInterpConstantTo(current, target, delta_time, interp_speed)

Parameters

TypeParameterDefaultDescription
Rotatorcurrent Required parameter The current value
Rotatortarget Required parameter The target value
floatdelta_time Required parameter Time since the last call, usually the Tick delta time
floatinterp_speed Required parameter Interpolation speed, 0 jumps straight to the target

Returns

TypeDescription
RotatorThe interpolated Rotator

Optimal

VInterpTo​

Interpoler le Vector de "Actuel" vers "Cible"
local ret = NanosMath.VInterpTo(current, target, delta_time, interp_speed)

Parameters

TypeParameterDefaultDescription
Vectorcurrent Required parameter The current value
Vectortarget Required parameter The target value
floatdelta_time Required parameter Time since the last call, usually the Tick delta time
floatinterp_speed Required parameter Interpolation speed, 0 jumps straight to the target

Returns

TypeDescription
VectorThe interpolated Vector
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)

Optimal

VInterpConstantTo​

Interpoler le Vector de "Actuel" vers "Cible" avec une évolution constante
local ret = NanosMath.VInterpConstantTo(current, target, delta_time, interp_speed)

Parameters

TypeParameterDefaultDescription
Vectorcurrent Required parameter The current value
Vectortarget Required parameter The target value
floatdelta_time Required parameter Time since the last call, usually the Tick delta time
floatinterp_speed Required parameter Interpolation speed, 0 jumps straight to the target

Returns

TypeDescription
VectorThe interpolated Vector