BrawlCrate v0.41
Wii File Editor
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
BrawlLib.Internal.SingleExtension Class Reference

Static Public Member Functions

static unsafe float Reverse (this float value)
 
static float Clamp (this float value, float min, float max)
 
static float RemapToRange (this float value, float min, float max)
 Remaps values outside of a range into the first multiple of that range. When it comes to signed numbers, negative is highest. For example, -128 (0xFF) vs 127 (0x7F). Because of this, the max value is non-inclusive while the min value is. More...
 

Member Function Documentation

◆ Clamp()

static float BrawlLib.Internal.SingleExtension.Clamp ( this float  value,
float  min,
float  max 
)
inlinestatic
19 {
20 return value <= min ? min : value >= max ? max : value;
21 }

◆ RemapToRange()

static float BrawlLib.Internal.SingleExtension.RemapToRange ( this float  value,
float  min,
float  max 
)
inlinestatic

Remaps values outside of a range into the first multiple of that range. When it comes to signed numbers, negative is highest. For example, -128 (0xFF) vs 127 (0x7F). Because of this, the max value is non-inclusive while the min value is.

30 {
31 //Check if the value is already in the range
32 if (value < max && value >= min)
33 {
34 return value;
35 }
36
37 //Get the distance between max and min
38 float range = max - min;
39
40 //First figure out how many multiples of the range there are.
41 //Dividing the value by the range and cutting off the decimal places
42 //will return the number of multiples of whole ranges in the value.
43 //Those multiples need to be subtracted out.
44 value -= range * (int) (value / range);
45
46 //Now the value is in the range of +range to -range.
47 //The value needs to be within +(range/2) to -(range/2).
48 value += value > max ? -range : value < min ? range : 0;
49
50 //Max value is non-inclusive
51 if (value == max)
52 {
53 value = min;
54 }
55
56 return value;
57 }

◆ Reverse()

static unsafe float BrawlLib.Internal.SingleExtension.Reverse ( this float  value)
inlinestatic
6 {
7 *(uint*) &value = ((uint*) &value)->Reverse();
8 return value;
9 }
static unsafe float Reverse(this float value)
Definition: SingleExtension.cs:5

The documentation for this class was generated from the following file: