mirror of
https://github.com/MonsterDruide1/OdysseyDecomp
synced 2026-04-23 09:04:21 +00:00
Start on some math utilities
This commit is contained in:
parent
c287cccfc7
commit
65cdc39f12
9
.gitignore
vendored
9
.gitignore
vendored
|
|
@ -1,9 +0,0 @@
|
|||
*.o
|
||||
*.vscode
|
||||
|
||||
# IDA Files
|
||||
*.id0
|
||||
*.id1
|
||||
*.id2
|
||||
*.nam
|
||||
*.til
|
||||
4
include/al/util/MathUtil.h
Normal file
4
include/al/util/MathUtil.h
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
namespace al
|
||||
{
|
||||
float normalize(signed int, signed int, signed int);
|
||||
};
|
||||
27
source/al/util/MathUtil.cpp
Normal file
27
source/al/util/MathUtil.cpp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include <MathUtil.h>
|
||||
|
||||
float normalize(signed int var, signed int min, signed int max)
|
||||
{
|
||||
signed int v3;
|
||||
float result;
|
||||
|
||||
if ( var <= min )
|
||||
return 0.0;
|
||||
if ( max - min <= 0 )
|
||||
{
|
||||
result = 1.0;
|
||||
if ( var < min )
|
||||
result = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( var <= max )
|
||||
v3 = var;
|
||||
else
|
||||
v3 = max;
|
||||
if ( var < min )
|
||||
v3 = min;
|
||||
result = (v3 - min) / (max - min);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Loading…
Reference in a new issue