SaturnRingLibrary 0.7
SGL wrapper
 
Loading...
Searching...
No Matches
SRL::Math Namespace Reference

Detailed Description

SaturnMath++ library functions.

SaturnMath++ is a C++23 library dedicated to Sega Saturn hardware, offering essential mathematical operations tailored for fixed-point arithmetic and geometric calculations.
Project url: Here

Classes

class  Integer
 Integer-specific utility functions optimized for performance. More...
 
class  Interpolation
 Class containing interpolation and easing functions optimized for fixed-point arithmetic. More...
 
class  Random
 Pseudo-Random number generator. More...
 
class  Trigonometry
 Core trigonometric functionality using fixed-point arithmetic. More...
 

Enumerations

enum class  Precision { Standard , Fast , Turbo }
 Specifies the precision level for mathematical operations. More...
 
enum class  SortOrder { Ascending , Descending }
 Specifies the order for sorting operations. More...
 

Functions

template<typename ValueType >
static constexpr ValueType Abs (const ValueType &value)
 Get absolute value.
 
template<typename T >
static constexpr T Clamp (const T &value, const T &min, const T &max)
 Clamps a value between min and max bounds.
 
template<typename ValueType >
static constexpr ValueType Max (const ValueType &first, const ValueType &second)
 Get maximum value of two values.
 
template<typename ValueType >
static constexpr ValueType Min (const ValueType &first, const ValueType &second)
 Get minimum value of two values.
 

Enumeration Type Documentation

◆ Precision

enum class SRL::Math::Precision
strong

Specifies the precision level for mathematical operations.

Different precision levels offer a trade-off between accuracy and performance:

  • Standard: Full precision calculations, ideal for critical computations
  • Fast: Good approximation with better performance
  • Turbo: Fastest calculation with acceptable accuracy, best for real-time effects
Enumerator
Standard 

Standard precision using full calculations.

Fast 

Fast approximation with good accuracy.

Turbo 

Fastest approximation with acceptable accuracy.

◆ SortOrder

enum class SRL::Math::SortOrder
strong

Specifies the order for sorting operations.

Enumerator
Ascending 

Sort in ascending order (smallest to largest)

Descending 

Sort in descending order (largest to smallest)

Function Documentation

◆ Abs()

template<typename ValueType >
static constexpr ValueType SRL::Math::Abs ( const ValueType & value)
staticconstexpr

Get absolute value.

Works with any type that supports comparison operators.

Template Parameters
ValueTypeType of the value
Parameters
valueNumeric value
Returns
Absolute value

◆ Clamp()

template<typename T >
static constexpr T SRL::Math::Clamp ( const T & value,
const T & min,
const T & max )
staticconstexpr

Clamps a value between min and max bounds.

Works with any type that supports comparison operators.

Template Parameters
TType of the values
Parameters
valueValue to clamp
minMinimum allowed value
maxMaximum allowed value
Returns
Clamped value

◆ Max()

template<typename ValueType >
static constexpr ValueType SRL::Math::Max ( const ValueType & first,
const ValueType & second )
staticconstexpr

Get maximum value of two values.

Works with any type that supports comparison operators.

Template Parameters
ValueTypeType of the value
Parameters
firstFirst value
secondSecond value
Returns
Maximum value

◆ Min()

template<typename ValueType >
static constexpr ValueType SRL::Math::Min ( const ValueType & first,
const ValueType & second )
staticconstexpr

Get minimum value of two values.

Works with any type that supports comparison operators.

Template Parameters
ValueTypeType of the value
Parameters
firstFirst value
secondSecond value
Returns
Minimum value