KS.Reactor.ksRange Class Reference

Defines a numerical range that wraps around. More...

Public Member Functions

 ksRange (float min, float max)
 Constructor. More...
 
void SetRange (float min, float max)
 Sets new min and max range values More...
 
float Wrap (float value)
 Fits a value into the range. More...
 
float Clamp (float value)
 Clamps a value into the range. More...
 
float Delta (float from, float to)
 Calculates the shortest delta between two values. More...
 
float Slerp (float from, float to, float t)
 Spherically interpolates between two values. More...
 
float MoveTowards (float start, float target, float distance)
 Moves a value towards another in the shorest direction. More...
 

Properties

static ksRange Degrees [get]
 Degrees (0 - 360). More...
 
static ksRange Radians [get]
 Radians (0 - 2PI). More...
 
float Min [get]
 Min value in the range (inclusive). More...
 
float Max [get]
 Max value in the range (exclusive). More...
 

Detailed Description

Defines a numerical range that wraps around.

Constructor & Destructor Documentation

◆ ksRange()

KS.Reactor.ksRange.ksRange ( float  min,
float  max 
)

Constructor.

Parameters
minMin value in the range (inclusive).
maxMax value in the range (exclusive).

Member Function Documentation

◆ Clamp()

float KS.Reactor.ksRange.Clamp ( float  value)

Clamps a value into the range.

Parameters
value
Returns
Clamped value.

◆ Delta()

float KS.Reactor.ksRange.Delta ( float  from,
float  to 
)

Calculates the shortest delta between two values.

Parameters
from
to
Returns
Delta between from and to.

◆ MoveTowards()

float KS.Reactor.ksRange.MoveTowards ( float  start,
float  target,
float  distance 
)

Moves a value towards another in the shorest direction.

Parameters
startStart value.
targetTarget to move towards.
distancedelta distance to move. It will not overshoot the target. Negative values will move away from the target.
Returns
Result.

◆ SetRange()

void KS.Reactor.ksRange.SetRange ( float  min,
float  max 
)

Sets new min and max range values

Parameters
minMin value in the range (inclusive).
maxMax value in the range (exclusive).

◆ Slerp()

float KS.Reactor.ksRange.Slerp ( float  from,
float  to,
float  t 
)

Spherically interpolates between two values.

Parameters
fromValue to interpolate from.
toValue to interpolate to.
tAmount to interpolate between 0 and 1.
Returns
Interpolated value.

◆ Wrap()

float KS.Reactor.ksRange.Wrap ( float  value)

Fits a value into the range.

This is not a clamp–values outside the range will wrap around.

Parameters
value
Returns
Value in range.

Property Documentation

◆ Degrees

ksRange KS.Reactor.ksRange.Degrees
staticget

Degrees (0 - 360).

◆ Max

float KS.Reactor.ksRange.Max
get

Max value in the range (exclusive).

◆ Min

float KS.Reactor.ksRange.Min
get

Min value in the range (inclusive).

◆ Radians

ksRange KS.Reactor.ksRange.Radians
staticget

Radians (0 - 2PI).