CGPdocs

Scalar math and comparisons

abs, clamp and linear interpolation of numbers, and comparisons with a tolerance.

Transform 1

unsigned long long abs(unsigned long long a)

Absolute value of an unsigned integer, i.e. the value itself.

Compute 13

abs

11 overloads
float abs(float a)
source

Absolute value of a float (std::abs).

double abs(double a)
source

Absolute value of a double (std::abs).

char abs(char a)
source

Absolute value of a signed char.

short abs(short a)
source

Absolute value of a signed short.

int abs(int a)
source

Absolute value of a signed int.

long abs(long a)
source

Absolute value of a signed long.

long long abs(long long a)
source

Absolute value of a signed long long.

unsigned char abs(unsigned char a)
source

Absolute value of an unsigned integer, i.e. the value itself.

unsigned short abs(unsigned short a)
source

Absolute value of an unsigned integer, i.e. the value itself.

unsigned int abs(unsigned int a)
source

Absolute value of an unsigned integer, i.e. the value itself.

unsigned long abs(unsigned long a)
source

Absolute value of an unsigned integer, i.e. the value itself.

template <typename T1, typename T2>
T1 clamp(T1 x, T2 x_min, T2 x_max)

Clamps x to the interval [x_min, x_max].

template <typename T>
T interpolation_linear(float alpha, T const& value_0, T const& value_1)

Linear interpolation (1-alpha)*value_0 + alpha*value_1, with alpha expected in [0,1].

Access 10

is_equal

10 overloads
bool is_equal(float a, float b)
source

Approximate equality of two floats: true if |a-b| <= 1e-5.

bool is_equal(double a, double b)
source

Approximate equality of two doubles: true if |a-b| <= 1e-7.

bool is_equal(float a, double b)
source

Approximate equality of a float and a double, compared in float precision with tolerance 1e-5.

bool is_equal(double a, float b)
source

Approximate equality of a double and a float, compared in float precision with tolerance 1e-5.

template <typename T1, typename T2>
bool is_equal(T1 const& a, T2 const& b)
source

Generic fallback equality test using operator== (exact comparison).

template <typename T1, typename T2, size_t N>
bool is_equal(std::array<T1,N> const& a, std::array<T2,N> const& b)
source

Element-wise equality of two std::array, approximate for floating-point elements.

template <typename T1, typename T2>
bool is_equal(std::vector<T1> const& a, std::vector<T2> const& b)
source

Element-wise equality of two std::vector, approximate for floating-point elements; false if sizes differ.

bool is_equal(std::string const& a, std::string const& b)
source

Exact equality of two strings.

bool is_equal(std::string const& a, char const* b)
source

Exact equality of a string and a C-string.

bool is_equal(char const* a, std::string const& b)
source

Exact equality of a C-string and a string.

CGP - Computer Graphics Programming.