Closed RealityProgrammer closed 1 year ago
Can you explain what purpose Wrap
serves? It seems like it behaves as Clamp
.
Same with Normalize
Perhaps example inputs and outputs will help clarify
Wrap method will wrap the value around between 2 boundaries instead of clamping, so if it's overflow or underflow, it will rewrap on the otherside. Normalize method is just normalize value between a and b in form of 0 to 1, a bit awkward is it will never returns 1 but wrap back to 0 because of division
Ah so Wrap
serves as modulo with offset, understood.
And Normalize
is redundant because it's essentially InverseLerp
I know we discussed this in the server, just leaving this note here for myself
Not exactly like C# modulo but another way to explain it that going through one end, you end up in another end like Portal
And the reason for extra complicated calculation is to make it works for negative number, still apply the same principle
Wrap around in an endless loop
14 was added with eadb66f47002724c8a149142e81c83e25f6a987f under the name ScaleRange
Type to extend
Various (though primarily
float
)Signature
Wrap(float value, float low, float high)
Wrap(int value, int low, int high)
Wrap(float value, float length)
Wrap(int value, int length)
InverseLerp(float value, float a, float b)
Bias(float value, float bias)
Pulse(float value, float a, float b)
Saw(float value, float magnitude)
Gamma(float value, float gamma)
Sigmoid(float x)
SmoothStep(float a, float b, float x)
Saturate(float x)
Normalize(float value, float min, float max)
Remap(float value, float inmin, float inmax, float outmin, float outmax)
ExpoDecay(float value, float t, float decay)
LinearToGamma(float linear)
GammaToLinear(float gamma)
Summary
Parameters
float
orint
float
orint
float
orint
float
orint
float
orint
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
float
Benefits
Some useless math function but might be fun to add some
Drawbacks
Might need rewrite after generic math come out
Implementation Example
1 + 2.
3 + 4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
Code of Conduct