galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::math Namespace Reference

Classes

struct  fnv_1a_params
 Base specialization for fnv1a params. More...
 
struct  fnv_1a_params< std::uint32_t >
 Fnv1a 32 bit specialization. More...
 
struct  fnv_1a_params< std::uint64_t >
 Fnv1a 64 bit specialization. More...
 
class  Random
 Generates random numbers. More...
 
class  RectPack
 Rectangle 2D bin packing class. More...
 
class  ZLib
 Compressor and Decompressor. More...
 

Concepts

concept  valid_fnv_bits
 Concept to enforce fnv bit types.
 

Typedefs

template<typename Type >
using conditional_distribution
 Source: http://stackoverflow.com/a/32907541.
 

Functions

std::string encode_base64 (const std::string &input)
 Compresses string into Base64.
 
std::string decode_base64 (const std::string &input)
 Decompresses string into Base64.
 
template<valid_fnv_bits bits = std::uint64_t>
constexpr bits fnv1a (const char *const str, const bits value=fnv_1a_params< bits >::offset) noexcept
 Convert string to hash.
 
template<meta::is_arithmetic Type>
float normalize (const Type val, const Type max) noexcept
 Calc normalized value from range.
 
template<typename Type >
bool contains (const std::vector< Type > &cont, const Type &val) noexcept
 See if a vector contains a value.
 
std::string encode_zlib (const std::string &input)
 Compresses string into ZLib.
 
std::string decode_zlib (const std::string &input)
 Decompresses string into ZLib.
 

Typedef Documentation

◆ conditional_distribution

template<typename Type >
using galaxy::math::conditional_distribution
Initial value:
std::conditional_t<
std::is_integral<Type>::value,
std::uniform_int_distribution<Type>,
std::conditional_t<std::is_floating_point<Type>::value, std::uniform_real_distribution<Type>, void>>

Source: http://stackoverflow.com/a/32907541.

Definition at line 26 of file Random.hpp.

Function Documentation

◆ encode_base64()

std::string galaxy::math::encode_base64 ( const std::string & input)
nodiscard

Compresses string into Base64.

The MIT License (MIT) Copyright(c) 2016 tomykaira

Parameters
inputInput data to convert.
Returns
Returns output data if successful, std::nullopt otherwise.

Definition at line 51 of file Base64.cpp.

+ Here is the caller graph for this function:

◆ decode_base64()

std::string galaxy::math::decode_base64 ( const std::string & input)
nodiscard

Decompresses string into Base64.

The MIT License (MIT) Copyright(c) 2016 tomykaira

Parameters
inputInput data to convert.
Returns
Returns output data if successful, std::nullopt otherwise.

Definition at line 105 of file Base64.cpp.

+ Here is the caller graph for this function:

◆ fnv1a()

template<valid_fnv_bits bits = std::uint64_t>
bits galaxy::math::fnv1a ( const char *const str,
const bits value = fnv_1a_params<bits>::offset )
inlineconstexprnoexcept

Convert string to hash.

Template Parameters
bits32 or 64 bit type.
Parameters
strString to hash.
valueHashing value passed recursively.
Returns
Unsigned 32 or 64 bit integer.

Definition at line 64 of file FNV1a.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normalize()

template<meta::is_arithmetic Type>
float galaxy::math::normalize ( const Type val,
const Type max )
inlinenodiscardnoexcept

Calc normalized value from range.

Template Parameters
TypeArithmetic type to normalize.
Parameters
valValue to divide by max.
maxValue representing 1.0f.
Returns
Normalized float.

Definition at line 32 of file Generic.hpp.

+ Here is the caller graph for this function:

◆ contains()

template<typename Type >
bool galaxy::math::contains ( const std::vector< Type > & cont,
const Type & val )
inlinenodiscardnoexcept

See if a vector contains a value.

Template Parameters
TypeVector type. Must have an overloaded '==' operator.
Parameters
contContainer to check.
valValue to look for.
Returns
True if found.

Definition at line 49 of file Generic.hpp.

◆ encode_zlib()

std::string galaxy::math::encode_zlib ( const std::string & input)
nodiscard

Compresses string into ZLib.

Parameters
inputInput data to convert.
Returns
Returns output data if successful, std::nullopt otherwise.

Definition at line 234 of file ZLib.cpp.

+ Here is the caller graph for this function:

◆ decode_zlib()

std::string galaxy::math::decode_zlib ( const std::string & input)
nodiscard

Decompresses string into ZLib.

Parameters
inputInput data to convert.
Returns
Returns output data if successful, std::nullopt otherwise.

Definition at line 276 of file ZLib.cpp.

+ Here is the caller graph for this function: