|
|
@@ -9,10 +9,6 @@
|
|
|
|
|
|
namespace crown
|
|
|
{
|
|
|
-/// @addtogroup Math
|
|
|
-/// @{
|
|
|
-
|
|
|
-/// Returns whether @a a and @a b are equal according to @a epsilon.
|
|
|
bool fequal(f32 a, f32 b, f32 epsilon)
|
|
|
{
|
|
|
return b <= (a + epsilon)
|
|
|
@@ -20,31 +16,26 @@ bool fequal(f32 a, f32 b, f32 epsilon)
|
|
|
;
|
|
|
}
|
|
|
|
|
|
-/// Returns the minimum of @a a and @a b.
|
|
|
f32 fmin(f32 a, f32 b)
|
|
|
{
|
|
|
return a < b ? a : b;
|
|
|
}
|
|
|
|
|
|
-/// Returns the maximum of @a a and @a b.
|
|
|
f32 fmax(f32 a, f32 b)
|
|
|
{
|
|
|
return a < b ? b : a;
|
|
|
}
|
|
|
|
|
|
-/// Clamps @a val to @a min and @a max.
|
|
|
f32 fclamp(f32 min, f32 max, f32 val)
|
|
|
{
|
|
|
return fmin(fmax(min, val), max);
|
|
|
}
|
|
|
|
|
|
-/// Returns the fractional part of @a a.
|
|
|
f32 ffract(f32 a)
|
|
|
{
|
|
|
return a - floorf(a);
|
|
|
}
|
|
|
|
|
|
-/// Returns the absolute value of @a a.
|
|
|
f32 fabs(f32 a)
|
|
|
{
|
|
|
return ::fabsf(a);
|
|
|
@@ -60,7 +51,6 @@ f32 fcos(f32 a)
|
|
|
return cosf(a);
|
|
|
}
|
|
|
|
|
|
-/// Returns the arc cosine of @a a.
|
|
|
f32 facos(f32 a)
|
|
|
{
|
|
|
return ::acosf(a);
|
|
|
@@ -73,28 +63,24 @@ f32 ftan(f32 a)
|
|
|
|
|
|
f32 fsqrt(f32 a)
|
|
|
{
|
|
|
- return fsqrt(a);
|
|
|
+ return sqrtf(a);
|
|
|
}
|
|
|
|
|
|
-/// Returns @a deg in radians.
|
|
|
f32 frad(f32 deg)
|
|
|
{
|
|
|
return deg * PI / 180.0f;
|
|
|
}
|
|
|
|
|
|
-/// Returns @a rad in degrees.
|
|
|
f32 fdeg(f32 rad)
|
|
|
{
|
|
|
return rad * 180.0f / PI;
|
|
|
}
|
|
|
|
|
|
-/// Returns the linear interpolated value between @a p0 and @a p1 at time @a t
|
|
|
f32 lerp(const f32 p0, const f32 p1, f32 t)
|
|
|
{
|
|
|
return (1.0f - t) * p0 + t * p1;
|
|
|
}
|
|
|
|
|
|
-/// Returns the cosine interpolated value between @a p0 and @a p1 at time @a t
|
|
|
f32 cosine(const f32 p0, const f32 p1, f32 t)
|
|
|
{
|
|
|
const f32 f = t * PI;
|
|
|
@@ -103,7 +89,6 @@ f32 cosine(const f32 p0, const f32 p1, f32 t)
|
|
|
return p0 + g * (p1 - p0);
|
|
|
}
|
|
|
|
|
|
-/// Returns the cubic interpolated value between @a p0 and @a p1 at time @a t
|
|
|
f32 cubic(const f32 p0, const f32 p1, f32 t)
|
|
|
{
|
|
|
const f32 tt = t * t;
|
|
|
@@ -112,7 +97,6 @@ f32 cubic(const f32 p0, const f32 p1, f32 t)
|
|
|
return p0 * (2.0f * ttt - 3.0f * tt + 1.0f) + p1 * (3.0f * tt - 2.0f * ttt);
|
|
|
}
|
|
|
|
|
|
-/// Bezier interpolation
|
|
|
f32 bezier(const f32 p0, const f32 p1, const f32 p2, const f32 p3, f32 t)
|
|
|
{
|
|
|
const f32 u = 1.0f - t;
|
|
|
@@ -129,7 +113,6 @@ f32 bezier(const f32 p0, const f32 p1, const f32 p2, const f32 p3, f32 t)
|
|
|
return tmp;
|
|
|
}
|
|
|
|
|
|
-/// Catmull-Rom interpolation
|
|
|
f32 catmull_rom(const f32 p0, const f32 p1, const f32 p2, const f32 p3, f32 t)
|
|
|
{
|
|
|
const f32 tt = t * t;
|
|
|
@@ -143,6 +126,4 @@ f32 catmull_rom(const f32 p0, const f32 p1, const f32 p2, const f32 p3, f32 t)
|
|
|
return tmp * 0.5f;
|
|
|
}
|
|
|
|
|
|
-/// @}
|
|
|
-
|
|
|
} // namespace crown
|