Browse Source

Add documentation to some math functions.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
0d4fc39854
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      include/math.hpp

+ 8
- 0
include/math.hpp View File

@@ -143,10 +143,14 @@ inline float chop(float x, float epsilon = 1e-6f) {
return std::fabs(x) <= epsilon ? 0.f : x;
}

/** Rescales `x` from the range `[xMin, xMax]` to `[yMin, yMax]`.
*/
inline float rescale(float x, float xMin, float xMax, float yMin, float yMax) {
return yMin + (x - xMin) / (xMax - xMin) * (yMax - yMin);
}

/** Linearly interpolates between `a` and `b`, from `p = 0` to `p = 1`.
*/
inline float crossfade(float a, float b, float p) {
return a + (b - a) * p;
}
@@ -177,6 +181,8 @@ inline void complexMult(float ar, float ai, float br, float bi, float* cr, float

struct Rect;

/** 2-dimensional vector of floats, representing a point in 2D space.
*/
struct Vec {
float x = 0.f;
float y = 0.f;
@@ -282,6 +288,8 @@ struct Vec {
};


/** 2-dimensional rectangle of floats.
*/
struct Rect {
Vec pos;
Vec size;


Loading…
Cancel
Save