Basic Mathematical Operations

## Files

file  interval.h

file  limits.h
Defines useful mathematical limits.

file  math.h
Assorted mathematical utility functions.

file  multiInterval.h

## Classes

class  GfInterval
A basic mathematical interval class. More...

class  GfMultiInterval
GfMultiInterval represents a subset of the real number line as an ordered set of non-intersecting GfIntervals. More...

## Macros

#define GF_MIN_VECTOR_LENGTH   1e-10
This constant is used to determine whether the length of a vector is too small to handle accurately. More...

## Functions

bool GfIsClose (double a, double b, double epsilon)
Returns true if `a` and `b` are with `epsilon` of each other. More...

Converts an angle in radians to degrees. More...

Converts an angle in degrees to radians. More...

template<class T >
double GfSqr (const T &x)
Returns the inner product of `x` with itself: specifically, `x*x`. More...

template<typename T >
GfSgn (T v)
Return the signum of `v` (i.e. More...

double GfSqrt (double f)
Return sqrt(`f`). More...

float GfSqrt (float f)
Return sqrt(`f`). More...

double GfExp (double f)
Return exp(`f`). More...

float GfExp (float f)
Return exp(`f`). More...

double GfLog (double f)
Return log(`f`). More...

float GfLog (float f)
Return log(`f`). More...

double GfFloor (double f)
Return floor(`f`). More...

float GfFloor (float f)
Return floor(`f`). More...

double GfCeil (double f)
Return ceil(`f`). More...

float GfCeil (float f)
Return ceil(`f`). More...

double GfAbs (double f)
Return abs(`f`). More...

float GfAbs (float f)
Return abs(`f`). More...

double GfRound (double f)
Return round(`f`). More...

float GfRound (float f)
Return round(`f`). More...

double GfPow (double f, double p)
Return pow(`f`, `p`). More...

float GfPow (float f, float p)
Return pow(`f`, `p`). More...

double GfSin (double v)
Return sin(`v`). More...

float GfSin (float v)
Return sin(`v`). More...

double GfCos (double v)
Return cos(`v`). More...

float GfCos (float v)
Return cos(`v`). More...

void GfSinCos (double v, double *s, double *c)
Return sin(`v`) in `s` and cos(`v`) in `c`. More...

void GfSinCos (float v, float *s, float *c)
Return sin(`v`) in `s` and cos(`v`) in `c`. More...

double GfClamp (double value, double min, double max)
Return the resulting of clamping `value` to lie between `min` and `max`. More...

float GfClamp (float value, float min, float max)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...

GF_API double GfMod (double a, double b)
The mod function with "correct" behaviour for negative numbers. More...

template<class T >
GfLerp (double alpha, const T &a, const T &b)
Linear interpolation function. More...

template<class T >
GfMin (T a1, T a2)
Returns the smallest of the given `values`. More...

template<class T >
GfMax (T a1, T a2)
Returns the largest of the given `values`. More...

template<typename Left , typename Right , std::enable_if_t< GfIsArithmetic< Left >::value &&GfIsArithmetic< Right >::value, int > = 0>
decltype(std::declval< Left >
()*std::declval< Right >())
GfDot (Left left, Right right)
Returns the dot (inner) product of two vectors. More...

template<typename Left , typename Right , std::enable_if_t< GfIsArithmetic< Left >::value &&GfIsArithmetic< Right >::value, int > = 0>
decltype(std::declval< Left >
()*std::declval< Right >())
GfCompMult (Left left, Right right)
Returns component-wise multiplication of vectors. More...

template<typename Left , typename Right , std::enable_if_t< GfIsArithmetic< Left >::value &&GfIsArithmetic< Right >::value, int > = 0>
decltype(std::declval< Left >
()/std::declval< Right >())
GfCompDiv (Left left, Right right)
Returns component-wise quotient of vectors. More...

## Macro Definition Documentation

 #define GF_MIN_VECTOR_LENGTH   1e-10

This constant is used to determine whether the length of a vector is too small to handle accurately.

Definition at line 34 of file limits.h.

## Function Documentation

 double GfAbs ( double f )
inline

Return abs(`f`).

Definition at line 115 of file math.h.

 float GfAbs ( float f )
inline

Return abs(`f`).

Definition at line 118 of file math.h.

 double GfCeil ( double f )
inline

Return ceil(`f`).

Definition at line 108 of file math.h.

 float GfCeil ( float f )
inline

Return ceil(`f`).

Definition at line 111 of file math.h.

 double GfClamp ( double value, double min, double max )
inline

Return the resulting of clamping `value` to lie between `min` and `max`.

This function is also defined for GfVecs.

Definition at line 156 of file math.h.

 float GfClamp ( float value, float min, float max )
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 164 of file math.h.

 decltype(std::declval() / std::declval()) GfCompDiv ( Left left, Right right )
inline

Returns component-wise quotient of vectors.

For scalar types, this is just the regular quotient.

Definition at line 264 of file math.h.

 decltype(std::declval() * std::declval()) GfCompMult ( Left left, Right right )
inline

Returns component-wise multiplication of vectors.

For scalar types, this is just the regular product.

Definition at line 253 of file math.h.

 double GfCos ( double v )
inline

Return cos(`v`).

Definition at line 142 of file math.h.

 float GfCos ( float v )
inline

Return cos(`v`).

Definition at line 145 of file math.h.

 double GfDegreesToRadians ( double degrees )
inline

Converts an angle in degrees to radians.

Definition at line 54 of file math.h.

 decltype(std::declval() * std::declval()) GfDot ( Left left, Right right )
inline

Returns the dot (inner) product of two vectors.

For scalar types, this is just the regular product.

Definition at line 242 of file math.h.

 double GfExp ( double f )
inline

Return exp(`f`).

Definition at line 87 of file math.h.

 float GfExp ( float f )
inline

Return exp(`f`).

Definition at line 90 of file math.h.

 double GfFloor ( double f )
inline

Return floor(`f`).

Definition at line 101 of file math.h.

 float GfFloor ( float f )
inline

Return floor(`f`).

Definition at line 104 of file math.h.

 bool GfIsClose ( double a, double b, double epsilon )
inline

Returns true if `a` and `b` are with `epsilon` of each other.

Definition at line 42 of file math.h.

 T GfLerp ( double alpha, const T & a, const T & b )
inline

Linear interpolation function.

For any type that supports multiplication by a scalar and binary addition, returns

* (1-alpha) * a + alpha * b
*

Definition at line 193 of file math.h.

 double GfLog ( double f )
inline

Return log(`f`).

Definition at line 94 of file math.h.

 float GfLog ( float f )
inline

Return log(`f`).

Definition at line 97 of file math.h.

 T GfMax ( T a1, T a2 )
inline

Returns the largest of the given `values`.

Definition at line 219 of file math.h.

 T GfMin ( T a1, T a2 )
inline

Returns the smallest of the given `values`.

Definition at line 200 of file math.h.

 GF_API double GfMod ( double a, double b )

The mod function with "correct" behaviour for negative numbers.

If `a` = `n` `b` for some integer `n`, zero is returned. Otherwise, for positive `a`, the value returned is `fmod(a,b)`, and for negative `a`, the value returned is `fmod(a,b)+b`.

 double GfPow ( double f, double p )
inline

Return pow(`f`, `p`).

Definition at line 129 of file math.h.

 float GfPow ( float f, float p )
inline

Return pow(`f`, `p`).

Definition at line 132 of file math.h.

inline

Converts an angle in radians to degrees.

Definition at line 48 of file math.h.

 double GfRound ( double f )
inline

Return round(`f`).

Definition at line 122 of file math.h.

 float GfRound ( float f )
inline

Return round(`f`).

Definition at line 125 of file math.h.

 T GfSgn ( T v )
inline

Return the signum of `v` (i.e.

-1, 0, or 1).

The type `T` must implement the < and > operators; the function returns zero only if value neither positive, nor negative.

Definition at line 74 of file math.h.

 double GfSin ( double v )
inline

Return sin(`v`).

Definition at line 136 of file math.h.

 float GfSin ( float v )
inline

Return sin(`v`).

Definition at line 139 of file math.h.

 void GfSinCos ( double v, double * s, double * c )
inline

Return sin(`v`) in `s` and cos(`v`) in `c`.

Definition at line 148 of file math.h.

 void GfSinCos ( float v, float * s, float * c )
inline

Return sin(`v`) in `s` and cos(`v`) in `c`.

Definition at line 151 of file math.h.

 double GfSqr ( const T & x )
inline

Returns the inner product of `x` with itself: specifically, `x*x`.

Defined for `int`, `float`, `double`, and all `GfVec` types.

Definition at line 62 of file math.h.

 double GfSqrt ( double f )
inline

Return sqrt(`f`).

Definition at line 80 of file math.h.

 float GfSqrt ( float f )
inline

Return sqrt(`f`).

Definition at line 83 of file math.h.