AverageValue

Description

sealed class Tinman.Terrain.Util.AverageValue

Computes a smoothed value by applying a moving average filter.

Public / Constructors

AverageValue


public constructor AverageValue → (2)

maximumAge opt : int32 = 100

[>=0]
Initial value for MaximumAge.

maximumCount opt : int32 = 100

[>=1]
Initial value for MaximumCount.

Creates a new instance of AverageValue.

Public / Methods

Add

2 overloads


public method Add1 → (1)

value in : float64

The value to add.

Adds a new value.


public method Add2 → (2)

value in : float64

The value to add.

now in : int32

The timestamp that corresponds to now (see LowLevel.TickCount).

Adds a new value.

Get

2 overloads


public method Get1 → ()

returns → float64

The current average value.

Returns the current average value.


public method Get2 → (1)

now in : int32

The timestamp that corresponds to now (see LowLevel.TickCount).

returns → float64

The current average value.

Returns the current average value.

Set

2 overloads


public method Set1 → (1)

value in : float64

The value sample to set.

Sets all value samples.


public method Set2 → (2)

value in : float64

The value sample to set.

now in : int32

The timestamp that corresponds to now (see LowLevel.TickCount).

Sets all value samples.

Public / Attributes

DefaultValue


public attribute DefaultValue → (get,set)

value : float64

The replacement value for non-numbers (see Maths.IsNumber).

The value to use when a given value sample is not-a-number or infinity.

Defaults to 0.

IsStable


public attribute IsStable → (get)

value : bool

true if all subsequent calls to Get1 resp. Get2 will return the same value,
false if the returned values might be different.

Is the current average value stable?

MaximumAge


public attribute MaximumAge → (get,set)

value : int32

[>=0]
The maximum age, in milli-seconds.

The maximum age of a value before it is discarded.

Defaults to 100.

MaximumCount


public attribute MaximumCount → (get,set)

value : int32

[>=1]
The maximum number of values.

The maximum number of values.

Defaults to 100.