Skip to content

Commit c009a03

Browse files
committed
Add INVLERP macro for inverse linear interpolation
1 parent 0e4d648 commit c009a03

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

math.gs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
# Linearly interpolate between `A` and `B` by `T`.
5858
%define LERP(A,B,T) ((A)+((B)-(A))*(T))
5959
60+
# Work out the ratio of `VAL` from `A` to `B`.
61+
%define INVLERP(VAL,A,B) ((VAL) - (A)) / ((B) - (A))
62+
6063
# Re-maps a `V` from the range `A` to `B` to the range `C` to `D`.
6164
%define MAP(A,B,C,D,V) (((V)-(B))*((D)-(C))/((A)-(B))+(C))
6265

0 commit comments

Comments
 (0)