HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
math.h File Reference
#include "pxr/pxr.h"
#include "pxr/base/arch/math.h"
#include "pxr/base/gf/api.h"
#include "pxr/base/gf/traits.h"
#include <type_traits>
+ Include dependency graph for math.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

PXR_NAMESPACE_OPEN_SCOPE bool GfIsClose (double a, double b, double epsilon)
 
double GfRadiansToDegrees (double radians)
 
double GfDegreesToRadians (double degrees)
 
template<class T >
double GfSqr (const T &x)
 
template<typename T >
GfSgn (T v)
 
double GfSqrt (double f)
 
float GfSqrt (float f)
 
double GfExp (double f)
 
float GfExp (float f)
 
double GfLog (double f)
 
float GfLog (float f)
 
double GfFloor (double f)
 
float GfFloor (float f)
 
double GfCeil (double f)
 
float GfCeil (float f)
 
double GfAbs (double f)
 
float GfAbs (float f)
 
double GfRound (double f)
 
float GfRound (float f)
 
double GfPow (double f, double p)
 
float GfPow (float f, float p)
 
double GfSin (double v)
 
float GfSin (float v)
 
double GfCos (double v)
 
float GfCos (float v)
 
void GfSinCos (double v, double *s, double *c)
 
void GfSinCos (float v, float *s, float *c)
 
double GfClamp (double value, double min, double max)
 
float GfClamp (float value, float min, float max)
 
GF_API double GfMod (double a, double b)
 
GF_API float GfMod (float a, float b)
 
template<class T >
GfLerp (double alpha, const T &a, const T &b)
 
template<class T >
GfMin (T a1, T a2)
 
template<class T >
GfMin (T a1, T a2, T a3)
 
template<class T >
GfMin (T a1, T a2, T a3, T a4)
 
template<class T >
GfMin (T a1, T a2, T a3, T a4, T a5)
 
template<class T >
GfMax (T a1, T a2)
 
template<class T >
GfMax (T a1, T a2, T a3)
 
template<class T >
GfMax (T a1, T a2, T a3, T a4)
 
template<class T >
GfMax (T a1, T a2, T a3, T a4, T a5)
 
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)
 
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)
 
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)
 

Detailed Description

Assorted mathematical utility functions.

Definition in file math.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.

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 
)
inline

Returns component-wise quotient of vectors. For scalar types, this is just the regular quotient.

Definition at line 264 of file math.h.

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

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

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

template<class T >
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.

template<class T >
T GfMax ( a1,
a2 
)
inline

Returns the largest of the given values.

Definition at line 219 of file math.h.

template<class T >
T GfMax ( a1,
a2,
a3 
)
inline

Definition at line 223 of file math.h.

template<class T >
T GfMax ( a1,
a2,
a3,
a4 
)
inline

Definition at line 227 of file math.h.

template<class T >
T GfMax ( a1,
a2,
a3,
a4,
a5 
)
inline

Definition at line 231 of file math.h.

template<class T >
T GfMin ( a1,
a2 
)
inline

Returns the smallest of the given values.

Definition at line 200 of file math.h.

template<class T >
T GfMin ( a1,
a2,
a3 
)
inline

Definition at line 204 of file math.h.

template<class T >
T GfMin ( a1,
a2,
a3,
a4 
)
inline

Definition at line 208 of file math.h.

template<class T >
T GfMin ( a1,
a2,
a3,
a4,
a5 
)
inline

Definition at line 212 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.

GF_API float GfMod ( float  a,
float  b 
)

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

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.

double GfRadiansToDegrees ( double  radians)
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.

template<typename T >
T GfSgn ( 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.

template<class T >
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.