7 #ifndef PXR_BASE_GF_MATH_H
8 #define PXR_BASE_GF_MATH_H
19 #include <type_traits>
26 return fabs(a-b) < epsilon;
32 return radians * (180.0 /
M_PI);
38 return degrees * (
M_PI / 180.0);
50 double slope0 = 0.0,
double slope1 = 0.0);
163 double GfSmoothRamp(
double tmin,
double tmax,
double t,
double w0,
double w1);
179 template <
typename T>
182 return (v < 0) ? -1 : ((v > 0) ? 1 : 0);
194 inline double GfExp(
double f) {
return std::exp(f); }
197 inline float GfExp(
float f) {
return std::exp(f); }
222 inline double GfAbs(
double f) {
return std::fabs(f); }
225 inline float GfAbs(
float f) {
return std::fabs(f); }
255 inline void GfSinCos(
double v,
double *
s,
double *
c) { ArchSinCos(v, s, c); }
258 inline void GfSinCos(
float v,
float *
s,
float *
c) { ArchSinCosf(v, s, c); }
264 if (value < min)
return min;
265 if (value > max)
return max;
272 if (value < min)
return min;
273 if (value > max)
return max;
285 double GfMod(
double a,
double b);
301 return (1-alpha)* a + alpha *
b;
308 return (a1 < a2 ? a1 : a2);
319 inline T GfMin(T a1, T a2, T a3, T a4, T a5) {
327 return (a1 < a2 ? a2 : a1);
338 inline T GfMax(T a1, T a2, T a3, T a4, T a5) {
348 inline decltype(std::declval<Left>() * std::declval<Right>())
359 inline decltype(std::declval<Left>() * std::declval<Right>())
369 GfIsArithmetic<Right>::value,
int> = 0>
370 inline decltype(std::declval<Left>() / std::declval<Right>())
378 #endif // PXR_BASE_GF_MATH_H
SYS_API double cos(double x)
decltype(std::declval< Left >()*std::declval< Right >()) GfCompMult(Left left, Right right)
double GfClamp(double value, double min, double max)
IMATH_HOSTDEVICE constexpr int floor(T x) IMATH_NOEXCEPT
GLsizei const GLfloat * value
vfloat4 sqrt(const vfloat4 &a)
GLboolean GLboolean GLboolean GLboolean a
GF_API double GfSmoothStep(double min, double max, double val, double slope0=0.0, double slope1=0.0)
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
void GfSinCos(double v, double *s, double *c)
T GfLerp(double alpha, const T &a, const T &b)
double GfPow(double f, double p)
ImageBuf OIIO_API pow(const ImageBuf &A, cspan< float > B, ROI roi={}, int nthreads=0)
GF_API double GfSmoothRamp(double tmin, double tmax, double t, double w0, double w1)
GLfloat GLfloat GLfloat alpha
GLboolean GLboolean GLboolean b
PXR_NAMESPACE_OPEN_SCOPE bool GfIsClose(double a, double b, double epsilon)
double GfDegreesToRadians(double degrees)
IMATH_HOSTDEVICE constexpr int ceil(T x) IMATH_NOEXCEPT
GF_API double GfMod(double a, double b)
decltype(std::declval< Left >()/std::declval< Right >()) GfCompDiv(Left left, Right right)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
decltype(std::declval< Left >()*std::declval< Right >()) GfDot(Left left, Right right)
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
#define PXR_NAMESPACE_CLOSE_SCOPE
OIIO_FORCEINLINE T log(const T &v)
vint4 rint(const vfloat4 &a)
OIIO_FORCEINLINE OIIO_HOSTDEVICE T radians(T deg)
Convert degrees to radians.
double GfRadiansToDegrees(double radians)
SYS_API double sin(double x)
OIIO_FORCEINLINE OIIO_HOSTDEVICE T degrees(T rad)
Convert radians to degrees.