DayZ Enforce
Script API
Static Private Member Functions | List of all members
EnMath Class Reference

#include <EnMath.h>

Static Private Member Functions

static proto float  Pow (float v, float power)
  Return power of v ^ power. More...
 
static proto int  Random (int min, int max)
  Returns a random int number between and min [inclusive] and max [exclusive]. More...
 
static int  RandomInclMax (int min, int max)
  Returns a random int number between and min [inclusive] and max [inclusive]. More...
 
static float  RandomFloat (float min, float max)
  Returns a random float number between and min [inclusive] and max [inclusive]. More...
 
static float  RandomFloat01 ()
  Returns a random float number between and min [inclusive] and max [inclusive]. More...
 
static proto float  RandomFloatExclMax (float min, float max)
  Returns a random float number between and min[inclusive] and max[exclusive]. More...
 
static proto int  Randomize (int seed)
  Sets the seed for the random number generator. More...
 
static proto float  NormalizeAngle (float ang)
  Normalizes the angle (0...360) More...
 
static proto float  AbsFloat (float f)
  Returns absolute value. More...
 
static proto int  Abs (int i)
  Returns absolute value. More...
 
static proto float  Sqrt (float val)
  Returns square root. More...
 
static proto float  Sin (float angle)
  Returns sinus of angle in radians. More...
 
static proto float  Cos (float angle)
  Returns cosinus of angle in radians. More...
 
static proto float  Tan (float deg)
  Returns tangent of angle in radians. More...
 
static proto float  Asin (float s)
  Returns angle in radians from sinus. More...
 
static proto float  Acos (float c)
  Returns angle in radians from cosinus. More...
 
static proto float  Atan2 (float y, float x)
  Returns angle in radians from tangent. More...
 
static proto float  Round (float f)
  Returns mathematical round of value. More...
 
static float  Clamp (float value, float min, float max)
  Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'. More...
 
static proto float  Floor (float f)
  Returns floor of value. More...
 
static proto float  Ceil (float f)
  Returns ceil of value. More...
 
static float  Min (float x, float y)
  Returns smaller of two given values. More...
 
static float  Max (float x, float y)
  Returns bigger of two given values. More...
 

Member Function Documentation

static proto float EnMath::Pow ( float  v,
float  power 
)
staticprivate

Return power of v ^ power.

Parameters
v float Value
power float Power
Returns
float - Angle in radians
Print( EnMath.Pow(2, 4) ); // (2*2*2*2)=16
>> 16
static proto int EnMath::Random ( int  min,
int  max 
)
staticprivate

Returns a random int number between and min [inclusive] and max [exclusive].

Parameters
min int Range starts [inclusive]
max int Range ends [exclusive]
Returns
int - Random number in range
Print( EnMath.Random(0, 1) ); // only 0
Print( EnMath.Random(0, 2) ); // 0 or 1
>> 0
>> 1

Referenced by EN5C_FishingRod_Base::Catching(), EN5C_PlantBase::EN5C_PlantBase(), EN5C_FishingRod_Base::FishPull(), EN5C_PlantBase::GrowthTimerTick(), EN5C_FishingRod_Base::Init(), PlayerStats::PlayerStats(), IngameHud::SetStamina(), and EN5C_PlantBase::StartGrowing().

static int EnMath::RandomInclMax ( int  min,
int  max 
)
staticprivate

Returns a random int number between and min [inclusive] and max [inclusive].

Parameters
min int Range starts [inclusive]
max int Range ends [inclusive]
Returns
int - Random number in range
Print( EnMath.RandomInclMax(0, 1) ); // 0 or 1
Print( EnMath.RandomInclMax(0, 2) ); // 0, 1, 2
>> 1
>> 2

References rand().

static float EnMath::RandomFloat ( float  min,
float  max 
)
staticprivate

Returns a random float number between and min [inclusive] and max [inclusive].

Parameters
min float Range starts [inclusive]
max float Range ends [inclusive]
Returns
float - Random number in range
Print( EnMath.RandomFloat(0, 1) ); // 0.0 .. 1.0
Print( EnMath.RandomFloat(1, 2) ); // 1.0 .. 2.0
>> 0.3
>> 2.0

References pow(), and random().

Referenced by RandomFloat01().

static float EnMath::RandomFloat01 ( )
staticprivate

Returns a random float number between and min [inclusive] and max [inclusive].

Returns
float - Random number in range 0.0 .. 1.0
Print( EnMath.RandomFloat01() ); // 0.0 .. 1.0
>> 0.3
>> 1.0

References RandomFloat().

Referenced by EN5C_FireplaceBase::CheckWind(), ModuleHorticulture::GiveWormsToPlayer(), and EN5C_PlantBase::InfestationTimerTick().

static proto float EnMath::RandomFloatExclMax ( float  min,
float  max 
)
staticprivate

Returns a random float number between and min[inclusive] and max[exclusive].

Parameters
min float Range starts [inclusive]
max float Range ends [exclusive]
Returns
float - Random number in range
>> 0.597561
>> 1.936456
static proto int EnMath::Randomize ( int  seed )
staticprivate

Sets the seed for the random number generator.

Parameters
seed int New seed for the random number generator
Returns
int - Returns new seed
>> 5
static proto float EnMath::NormalizeAngle ( float  ang )
staticprivate

Normalizes the angle (0...360)

Parameters
ang float Angle for normalizing
Returns
float - Normalized angle
>> 30
>> 270
static proto float EnMath::AbsFloat ( float  f )
staticprivate

Returns absolute value.

Parameters
f float Value
Returns
float - Absolute value
Print( EnMath.AbsFloat(-12.5) );
>> 12.5

Referenced by PlayerBase::IsFacingTarget().

static proto int EnMath::Abs ( int  i )
staticprivate
static proto float EnMath::Sqrt ( float  val )
staticprivate

Returns square root.

Parameters
val float Value
Returns
float - Square of value
>> 5
static proto float EnMath::Sin ( float  angle )
staticprivate

Returns sinus of angle in radians.

Parameters
angle float Angle in radians
Returns
float - Sinus of angle
Print( EnMath.Sin(0.785398) ); // (45)
>> 0.707107

Referenced by Rectangle2D::Rotate2DVector().

static proto float EnMath::Cos ( float  angle )
staticprivate

Returns cosinus of angle in radians.

Parameters
angle float Angle in radians
Returns
float - Cosinus of angle
Print( EnMath.Cos(0.785398) ); // (45)
>> 0.707107

Referenced by Rectangle2D::Rotate2DVector().

static proto float EnMath::Tan ( float  deg )
staticprivate

Returns tangent of angle in radians.

Parameters
deg float Angle in radians
Returns
float - Tangens of angle
Print( EnMath.Tan(0.785398) ); // (45)
>> 1
static proto float EnMath::Asin ( float  s )
staticprivate

Returns angle in radians from sinus.

Parameters
s float Sinus
Returns
float - Angle in radians
Print( EnMath.Asin(0.707107) ); // (sinus 45)
>> 0.785398
static proto float EnMath::Acos ( float  c )
staticprivate

Returns angle in radians from cosinus.

Parameters
c float Cosinus
Returns
float - Angle in radians
Print( EnMath.Acos(0.707107) ); // (cosinus 45)
>> 0.785398

Referenced by EN5C_FireplaceBase::IsFacingFireplace().

static proto float EnMath::Atan2 ( float  y,
float  x 
)
staticprivate

Returns angle in radians from tangent.

Parameters
y float Tangent
x float Tangent
Returns
float - Angle in radians
Print ( EnMath.Atan2(1, 1) );
>> 0.785398
static proto float EnMath::Round ( float  f )
staticprivate

Returns mathematical round of value.

Parameters
f float Value
Returns
int - closest whole number to 'f'
Print( EnMath.Round(5.3) );
Print( EnMath.Round(5.8) );
>> 5
>> 6

Referenced by ItemBase::ConfigVariableGetInt(), and EN5C_SeedPackBase::EmptySeedPack().

static float EnMath::Clamp ( float  value,
float  min,
float  max 
)
staticprivate

Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.

Parameters
value float Value
min float Minimum value
max float Maximum value
Returns
float - Clamped value
Print( EnMath.Floor(-0.1, 0, 1) );
Print( EnMath.Floor(2, 0, 1) );
Print( EnMath.Floor(0.5, 0, 1) );
>> 0
>> 1
>> 0.5

Referenced by EN5C_FireplaceBase::BurnItemsInCargo(), EN5C_FireplaceBase::CheckWind(), ItemBase::ConfigVariableSet(), ItemBase::ConfigVariableSetInt(), EN5C_FireplaceBase::Cooling(), EN5C_FireplaceBase::Heating(), ActionExtinguishFireplace::OnComplete(), ModulePlayerStatus::SetStamina(), EN5C_FireplaceBase::TransferHeatToNearObjects(), and Cooking::UpdateCookingState().

static proto float EnMath::Floor ( float  f )
staticprivate
static proto float EnMath::Ceil ( float  f )
staticprivate

Returns ceil of value.

Parameters
f float Value
Returns
int - Ceil of value
Print( EnMath.Ceil(5.3) );
Print( EnMath.Ceil(5.8) );
>> 6
>> 6

Referenced by EN5C_PlantBase::StartGrowing().

static float EnMath::Min ( float  x,
float  y 
)
staticprivate

Returns smaller of two given values.

Parameters
x float Value
y float Value
Returns
float - min value
Print( EnMath.Min(5.3, 2.8) );
>> 2.8

Referenced by StaminaCalc::OnTick(), and Environment::ProcessEnvironmentEffect().

static float EnMath::Max ( float  x,
float  y 
)
staticprivate

Returns bigger of two given values.

Parameters
x float Value
y float Value
Returns
float - max value
Print( EnMath.Max(5.3, 2.8) );
>> 5.3

Referenced by WidgetFadeTimer::OnUpdate(), and Environment::ProcessEnvironmentEffect().


The documentation for this class was generated from the following file:
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)