SAGE
A Simple Academic Game Engine
Loading...
Searching...
No Matches
SageHelpers.h File Reference

Header file for helper functions.

#include <chrono>
#include <ctime>
#include "SageDefines.h"
Include dependency graph for SageHelpers.h:
This graph shows which files directly or indirectly include this file:

Macros

#define SAFE_DELETE(p)
 Delete and set to nullptr for safety.
 

Functions

float Sage::lerp (const float, const float, const float)
 Linear interpolation.
 
float Sage::spline3 (const float)
 Cubic spline.
 
float Sage::spline5 (const float)
 Quintic spline.
 
template<typename t >
Sage::clamp (t a, t b, t c)
 Clamping function.
 
template<typename t >
Sage::sign (t x)
 Sign function.
 
template<typename t >
Sage::sqr (t x)
 Squaring function.
 
void Sage::MakeWideFileName (_In_ const char *, _Out_ wchar_t *&)
 Make wide file name from a narrow one.
 
XMFLOAT4 Sage::HSVtoRGB (float, float, float)
 Convert color from HSV to RGB.
 
template<typename t >
Sage::GetEpochTime ()
 

Macro Definition Documentation

◆ SAFE_DELETE

#define SAFE_DELETE ( p)
Value:
{delete (p); (p) = nullptr;};

Function Documentation

◆ 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
aLower bound.
bNumber to be clamped.
cUpper bound.
Template Parameters
tType of numbers to be clamped.
Returns
The value closest to b that is at least a and at most c.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetEpochTime()

template<typename t >
t Sage::GetEpochTime ( )

Unix epoch time, the number of seconds since the Unix epoch, which is Jan. 1, 1970 UTC, excluding leap seconds.

Template Parameters
tNumeric type of result.
Returns
Unix epoch time.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
hHue.
sSaturation.
vValue.
Returns
Color in RGB format with an alpha value of 1.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lerp()

float Sage::lerp ( const float t,
const float a,
const float b )

Linearly interpolate between two numbers by a fractional amount.

Parameters
tInterpolation amount, assume between 0 and 1.
aA number.
bAnother number.
Returns
A value interpolated linearly between a and b by amount t.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sign()

template<typename t >
t Sage::sign ( t x)

Compute the sign of a number.

Parameters
xA number.
Template Parameters
tType of number.
Returns
-1 if x is less than 0, 1 if x is at least 0.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
xA number.
Returns
The cubic spline of x.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
xA number.
Returns
The quintic spline of x.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sqr()

template<typename t >
t Sage::sqr ( t x)

Compute the square of a number.

Parameters
xA number.
Template Parameters
tType of number.
Returns
The number squared.
Here is the call graph for this function:
Here is the caller graph for this function: