libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Ship::Math Namespace Reference

Lightweight math utility functions used throughout the engine. More...

Functions

float clamp (float d, float min, float max)
 Clamps d to the inclusive range [min, max].
 
size_t HashCombine (size_t lhs, size_t rhs)
 Combines two size_t hash values into a single hash.
 
template<typename Numeric >
bool IsNumber (const std::string &s)
 Returns true if s represents a valid number of type Numeric.
 

Detailed Description

Lightweight math utility functions used throughout the engine.

Function Documentation

◆ clamp()

float Ship::Math::clamp ( float  d,
float  min,
float  max 
)

Clamps d to the inclusive range [min, max].

Parameters
dValue to clamp.
minLower bound.
maxUpper bound.
Returns
min if d < min, max if d > max, otherwise d.

◆ HashCombine()

size_t Ship::Math::HashCombine ( size_t  lhs,
size_t  rhs 
)

Combines two size_t hash values into a single hash.

Implements the standard "hash combine" technique from Boost: the result is sensitive to the order of arguments, so HashCombine(a, b) != HashCombine(b, a).

Parameters
lhsFirst hash value.
rhsSecond hash value.
Returns
Combined hash.

◆ IsNumber()

template<typename Numeric >
bool Ship::Math::IsNumber ( const std::string &  s)

Returns true if s represents a valid number of type Numeric.

Attempts to parse s using the standard stream extraction operator. Returns true only if parsing succeeds and consumes the entire string.

Template Parameters
NumericNumeric type to test against (e.g. int, float, double).
Parameters
sString to test.