Header file for helper functions.
#include <chrono>
#include <ctime>
#include "SageDefines.h"
|
| #define | SAFE_DELETE(p) |
| | Delete and set to nullptr for safety.
|
| |
◆ SAFE_DELETE
Value:{delete (p); (p) = nullptr;};
◆ clamp()
template<typename t >
| t Sage::clamp |
( |
t | a, |
|
|
t | b, |
|
|
t | c ) |
Given three numbers, clamp the second between the first and third.
- Parameters
-
| a | Lower bound. |
| b | Number to be clamped. |
| c | Upper bound. |
- Template Parameters
-
| t | Type of numbers to be clamped. |
- Returns
- The value closest to b that is at least a and at most c.
◆ GetEpochTime()
Unix epoch time, the number of seconds since the Unix epoch, which is Jan. 1, 1970 UTC, excluding leap seconds.
- Template Parameters
-
- Returns
- Unix epoch time.
◆ HSVtoRGB()
| XMFLOAT4 Sage::HSVtoRGB |
( |
float | h, |
|
|
float | s, |
|
|
float | v ) |
Convert color in HSV format to RGB format. This is a helper function for generating a pseudo-random color. I snagged it from the interwebs.
- Parameters
-
| h | Hue. |
| s | Saturation. |
| v | Value. |
- Returns
- Color in RGB format with an alpha value of 1.
◆ lerp()
| float Sage::lerp |
( |
const float | t, |
|
|
const float | a, |
|
|
const float | b ) |
Linearly interpolate between two numbers by a fractional amount.
- Parameters
-
| t | Interpolation amount, assume between 0 and 1. |
| a | A number. |
| b | Another number. |
- Returns
- A value interpolated linearly between a and b by amount t.
◆ MakeWideFileName()
| void Sage::MakeWideFileName |
( |
_In_ const char * | filename, |
|
|
_Out_ wchar_t *& | wfilename ) |
Helper function to make a wide file name out of a regular one. Creates a wide buffer and stores the wide version of a regular file name in it. Remember to delete the wide file name after it has been used.
- Parameters
-
| filename | [in] The original file name. |
| wfilename | [out] The wide file name. |
◆ sign()
Compute the sign of a number.
- Parameters
-
- Template Parameters
-
- Returns
- -1 if x is less than 0, 1 if x is at least 0.
◆ spline3()
| float Sage::spline3 |
( |
const float | x | ) |
|
Compute the cubic spline of a number. The cubic spline of \(x\) is \(x^2(2-2x)\).
- Parameters
-
- Returns
- The cubic spline of x.
◆ spline5()
| float Sage::spline5 |
( |
const float | x | ) |
|
Compute the quintic spline of a number. The quintic spline of \(x\) is \(x^3(10+3x(2x-5))\).
- Parameters
-
- Returns
- The quintic spline of x.
◆ sqr()
Compute the square of a number.
- Parameters
-
- Template Parameters
-
- Returns
- The number squared.