EvolvingNatFloat: Difference between revisions

From Vintage Story Wiki
No edit summary
Line 88: Line 88:
For every representation except smoothstep, linearnullify, the '''initalValue = 1'''<br>
For every representation except smoothstep, linearnullify, the '''initalValue = 1'''<br>


[[File:Txtpositiveclampedsinus.png|150px]]
[[File:Txtpositiveclampedsinus.png|200px]]
[[File:Txtcosinus.png|150px]]
[[File:Txtcosinus.png|200px]]
[[File:Txtidentical.png|150px]]
[[File:Txtidentical.png|200px]]
[[File:Txtinverselinear.png|150px]]<br><br>
[[File:Txtinverselinear.png|200px]]<br><br>
[[File:Txtlinear.png|150px]]
[[File:Txtlinear.png|200px]]
[[File:Txtlinearincrease.png|150px]]
[[File:Txtlinearincrease.png|200px]]
[[File:TxtlinearnullifyFirstValMinusFive.png|150px]]
[[File:TxtlinearnullifyFirstValMinusFive.png|200px]]
[[File:Txtlinearreduce.png|150px]]<br><br>
[[File:Txtlinearreduce.png|200px]]<br><br>
[[File:Txtquadratic.png|150px]]
[[File:Txtquadratic.png|200px]]
[[File:Txtroot.png|150px]]
[[File:Txtroot.png|200px]]
[[File:Txtsinus.png|150px]]
[[File:Txtsinus.png|200px]]
[[File:Txtsmoothstep.png|150px]]
[[File:Txtsmoothstep.png|200px]]

Revision as of 12:43, 13 April 2020

EvolvingNatFloat

A number generator whose return value changes over time according to a transform and factor.
Each sequential value is retrieved according to the first value and the sequence number.

To use EvolvingNatFloat, add the using statement for Vintagestory.API.MathTools.

Important note: The value of sequence should always satisfy sequence >= 0

Example in code

using Vintagestory.API.MathTools;

class Example
{
    Example()
    {
        float factor = 1;

        EvolvingNatFloat evolve;
        evolve = new EvolvingNatFloat(
            EnumTransformFunction.CLAMPEDPOSITIVESINUS,
            factor

        );

        float firstValue = 5;
        for (float sequence = firstValue; sequence < 100; sequence++)
        {
            // Retrieve each sequential value
            float y = evolve.nextFloat(firstValue, sequence);
        }
    }
}

Transform variants

Overview
Name Explanation
clampedpositivesinus Clamped positive sine wave function.
cosinus Cosine wave function.
identical Identical to first value.
inverselinear Linear change in the direction of the first value.
linearnullify Linear change towards zero, then clamp at zero.
linearreduce Linear change in the opposite direction of the first value.
quadratic Quadratic function.
root Root function.
sinus Sine wave function.
smoothstep Smooth step function.

Visual representation

For every representation except smoothstep, the factor = 1
For every representation except smoothstep, linearnullify, the initalValue = 1

Txtpositiveclampedsinus.png Txtcosinus.png Txtidentical.png Txtinverselinear.png

Txtlinear.png Txtlinearincrease.png TxtlinearnullifyFirstValMinusFive.png Txtlinearreduce.png

Txtquadratic.png Txtroot.png Txtsinus.png Txtsmoothstep.png