Nuke binary plugins 15.1.4
 
Loading...
Searching...
No Matches
DDMath.h File Reference

Use <DDImage/DDMath.h> instead of <math.h> to make portable programs. More...

Macros

#define rintf(v)
 
#define M_PI_F
 
#define M_PI_2_F
 
#define M_PI_4_F
 
#define M_1_PI_F
 
#define M_2_PI_F
 
#define M_SQRT2_F
 
#define M_SQRT1_2_F
 
#define iman_
 
#define mFnVolatile
 
#define INFINITY
 
#define NAN
 

Functions

long fast_rint (double val)
 
long fast_floor (double val)
 
double radians (double degrees)
 
float radiansf (float degrees)
 
double degrees (double radians)
 
float degreesf (float radians)
 
template<class Type >
Type MIN (const Type &a, const Type &b)
 
template<class Type >
Type MAX (const Type &a, const Type &b)
 
template<class Type , class Typeb >
Type clamp (Type a, Typeb b, Typeb c)
 
template<class Type >
Type clamp (Type a)
 
template<class Type , class Typeb >
bool step (Type a, Typeb x)
 
template<class Type , class Typeb >
Type smoothstep (Type a, Type b, Typeb x)
 
template<class Type , class Typeb >
Type lerp (Type a, Type b, Typeb x)
 

Detailed Description

Use <DDImage/DDMath.h> instead of <math.h> to make portable programs.

This header file only contains inline functions and thus can be used in any code, whether or not it is linked with the DDImage library. It's primary purpose is to fix deficiencies in various platforms math header files.

  • Defines symbols and functions that are in the Linux math.h that are missing from NT.
  • Defines 'f' forms of all math functions that take and return a float on systems that don't have them.
  • Defines a number of templates and inline functions to do max, min, noise, clamping, and many functions from RenderMan and other shading languages.

See also <noise.h>

Function Documentation

◆ fast_rint()

long fast_rint ( double  val)
inline

◆ fast_floor()

long fast_floor ( double  val)
inline

Fast version of (int)floor(). Works for -32728 to 32727.99999236688, rounds numbers greater than n.9999923668 to n+1 rather than n. Requires IEEE floating point.

This doesn't work for numbers outside the bounds, but is 4x faster than standard floor within those bounds. Adding this bounds check doesn't seem to affect its performance, so this allows us to keep using the function

Referenced by DD::Image::Render::_request(), DD::Image::Iop::do_sample_shadowmap(), DD::Image::rTriangle::intersect_scanline(), and DD::Image::Transform::motionBlurSample().

◆ radians()

double radians ( double  degrees)
inline

◆ radiansf()

float radiansf ( float  degrees)
inline

Convert degrees to radians, returns a float.

References degrees().

◆ degrees()

double degrees ( double  radians)
inline

Convert radians to degrees.

References radians().

Referenced by radians(), and radiansf().

◆ degreesf()

float degreesf ( float  radians)
inline

Convert radians to degrees, returns a float.

References radians().

◆ MIN()

template<class Type >
Type MIN ( const Type &  a,
const Type &  b 
)
inline

◆ MAX()

template<class Type >
Type MAX ( const Type &  a,
const Type &  b 
)
inline

Takes the maximum of two things with a '<' operator. Returns b if either a or b is NaN. The function name is uppercase to avoid collisions with the many vender header files that define a macro or other template called max().

Referenced by DD::Image::Render::_validate(), DD::Image::DrawIop::_validate(), DD::Image::Quadtree< T >::add(), DD::Image::Render::draw_primitives(), DD::Image::Box3::expand(), DD::Image::NukeWrapper::maximum_inputs(), DD::Image::Box::merge(), DD::Image::NukeWrapper::NukeWrapper(), DD::Image::Row::range(), DD::Image::Iop::request(), and DD::Image::Scene::validate().

◆ clamp() [1/2]

template<class Type , class Typeb >
Type clamp ( Type  a,
Typeb  b,
Typeb  c 
)
inline

Restricts a to the range b through c for any type with a '<' operator. Returns b if either a or b or c is NaN.

Referenced by DD::Image::ComplexLightOp::_validate(), DD::Image::RenderScene::inputContext(), DD::Image::MergeOperation(), DD::Image::DrawIop::pixel_engine(), DD::Image::CameraOp::setHorizontalFov(), and DD::Image::Scene::validate().

◆ clamp() [2/2]

template<class Type >
Type clamp ( Type  a)
inline

Same as clamp(a,0,1)

◆ step()

template<class Type , class Typeb >
bool step ( Type  a,
Typeb  x 
)
inline

Returns 0 if x is less than a, returns 1 otherwise. Matches the function in RenderMan and other shading languages.

Referenced by DD::Image::Transform::append().

◆ smoothstep()

template<class Type , class Typeb >
Type smoothstep ( Type  a,
Type  b,
Typeb  x 
)
inline

Returns 0 if x is less than a, returns 1 if x is greater or equal to b, returns a smooth cubic interpolation otherwise. Matches the function in RenderMan and other shading languages.

◆ lerp()

template<class Type , class Typeb >
Type lerp ( Type  a,
Type  b,
Typeb  x 
)
inline

Returns a point on the line f(x) where f(0)==a and f(1)==b. Matches the function in RenderMan and other shading languages.

Referenced by DD::Image::NukeWrapper::uses_input().



©2024 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.foundry.com