Skip to content

Commit

Permalink
Add LERP(a, b, x) macro
Browse files Browse the repository at this point in the history
  • Loading branch information
maximecb committed Nov 30, 2023
1 parent aef97d4 commit 845a68f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ncc/include/uvm/math.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef __UVM_MATH_H__
#define __UVM_MATH_H__

//#include <assert.h>

// Minimum of two values
#ifndef MIN
#define MIN(a, b) (a < b? a:b)
Expand All @@ -18,6 +16,11 @@
#define CLAMP(x, min, max) MIN(MAX(x, min), max)
#endif

// Linear interpolation between two values
#ifndef LERP
#define LERP(a, b, x) ((1 - x) * a + (x * b))
#define LERP

// Remap a value from range [a0, a1] into range [b0, b1]
#ifndef REMAP
#define REMAP(v, a0, a1, b0, b1) (b0 + (b1 - b0) * ((v) - a0) / (a1 - a0))
Expand Down

0 comments on commit 845a68f

Please sign in to comment.