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...
 

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.
 
constexpr std::uint32_t fnv1a_32 (const char *const str) noexcept
 Convert string to 32bit hash.
 
constexpr std::uint64_t fnv1a_64 (const char *const str) noexcept
 Convert string to 64bit hash.
 
template<meta::is_arithmetic Arithmetic>
float constexpr normalize (const Arithmetic val, const Arithmetic max) noexcept
 Calc normalized value from range.
 
glm::vec2 random_vec2 (const glm::vec2 &min, const glm::vec2 &max) noexcept
 Generate a random vec2.
 
glm::vec3 random_vec3 (const glm::vec3 &min, const glm::vec3 &max) noexcept
 Generate a random vec3.
 
glm::vec4 random_vec4 (const glm::vec4 &min, const glm::vec4 &max) noexcept
 Generate a random vec4.
 
template<meta::is_arithmetic T>
random (const T min, const T max) noexcept
 Generate a random number of type T.
 

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 27 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:

◆ fnv1a_32()

std::uint32_t galaxy::math::fnv1a_32 ( const char *const str)
inlineconstexprnoexcept

Convert string to 32bit hash.

Convenience function.

Parameters
strString to hash.
Returns
Unsigned 32bit integer.

Definition at line 78 of file FNV1a.hpp.

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

◆ fnv1a_64()

std::uint64_t galaxy::math::fnv1a_64 ( const char *const str)
inlineconstexprnoexcept

Convert string to 64bit hash.

Convenience function.

Parameters
strString to hash.
Returns
Unsigned 64bit integer.

Definition at line 92 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 Arithmetic>
float constexpr galaxy::math::normalize ( const Arithmetic val,
const Arithmetic max )
inlinenodiscardconstexprnoexcept

Calc normalized value from range.

Template Parameters
ArithmeticType to normalize.
Parameters
valValue to divide by max.
maxValue representing 1.0f. I.e. 255.
Returns
Normalized float.

Definition at line 29 of file Math.hpp.

+ Here is the caller graph for this function:

◆ random_vec2()

glm::vec2 galaxy::math::random_vec2 ( const glm::vec2 & min,
const glm::vec2 & max )
nodiscardnoexcept

Generate a random vec2.

Parameters
minMinimum vec2 inclusive.
maxMaximum vec2 inclusive.
Returns
Pseudo-randomized vec2.

Definition at line 14 of file Random.cpp.

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

◆ random_vec3()

glm::vec3 galaxy::math::random_vec3 ( const glm::vec3 & min,
const glm::vec3 & max )
nodiscardnoexcept

Generate a random vec3.

Parameters
minMinimum vec3 inclusive.
maxMaximum vec3 inclusive.
Returns
Pseudo-randomized vec3.

Definition at line 19 of file Random.cpp.

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

◆ random_vec4()

glm::vec4 galaxy::math::random_vec4 ( const glm::vec4 & min,
const glm::vec4 & max )
nodiscardnoexcept

Generate a random vec4.

Parameters
minMinimum vec4 inclusive.
maxMaximum vec4 inclusive.
Returns
Pseudo-randomized vec4.

Definition at line 24 of file Random.cpp.

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

◆ random()

template<meta::is_arithmetic T>
T galaxy::math::random ( const T min,
const T max )
inlinenodiscardnoexcept

Generate a random number of type T.

Template Parameters
TThe type of number to return. Must be arithmetic.
Parameters
minMinimum number inclusive.
maxMaximum number inclusive.
Returns
Returns number of the same type as inputs.

Definition at line 44 of file Random.hpp.

+ Here is the caller graph for this function: