Functions
Math Functions

Math and comparison functions tuned for Arnold. More...

Functions

template<typename T >
AI_DEVICE constexpr T AiMin (T a, T b)
 Minimum of 'a' and 'b'.
 
template<typename T >
AI_DEVICE constexpr T AiMax (T a, T b)
 Maximum of 'a' and 'b'.
 
template<typename T >
AI_DEVICE constexpr T AiMin (T a, T b, T c)
 Minimum of three values: a, b, c.
 
template<typename T >
AI_DEVICE constexpr T AiMax (T a, T b, T c)
 Maximum of three values: a, b, c.
 
template<typename T >
AI_DEVICE constexpr T AiMin (T a, T b, T c, T d)
 Minimum of four values: a, b, c, d.
 
template<typename T >
AI_DEVICE constexpr T AiMax (T a, T b, T c, T d)
 Maximum of four values: a, b, c, d.
 
template<typename T >
AI_DEVICE constexpr T AiSqr (T a)
 Square of 'a'.
 
template<typename T >
AI_DEVICE constexpr T AiClamp (T v, T lo, T hi)
 Clamp the input to the specified range.
 
template<typename T >
AI_DEVICE constexpr T AiSafeAcos (T x)
 Safe arc cosine of 'x' (acos() returns NaN if x<-1 or x>1)
 
template<typename T1 , typename T2 >
AI_DEVICE constexpr T1 AiLerp (T2 t, T1 a, T1 b)
 Linear interpolation between 'a' and 'b' using 't' (0<=t<=1)
 
template<typename T >
AI_DEVICE constexpr T AiHerp01 (T t)
 Hermite interpolation between 0 and 1 using 't' (0<=t<=1)
 
template<typename T1 , typename T2 >
AI_DEVICE constexpr T1 AiHerp (T2 t, T1 a, T1 b)
 Hermite interpolation between 'a' and 'b' using 't' (0<=t<=1)
 
template<typename T1 , typename T2 >
AI_DEVICE T1 AiBiLerp (T2 s, T2 t, T1 c00, T1 c10, T1 c01, T1 c11)
 Bilinear interpolation between four float values using 's' and 't' (0<=st<=1)
 
template<typename T >
AI_DEVICE constexpr T AiBias (T a, T b)
 Bias function.
 
template<typename T >
AI_DEVICE constexpr T AiGain (T a, T g)
 Gain function.
 
template<typename T >
AI_DEVICE constexpr T AiStep (T x, T e)
 Step function.
 
template<typename T >
AI_DEVICE constexpr T AiFilterStep (T x, T e, T w)
 Filtered-step function.
 
template<typename T >
AI_DEVICE constexpr T AiLinearStep (T lo, T hi, T t)
 Linearly interpolated step from 'lo' to 'hi'. More...
 
template<typename T >
AI_DEVICE constexpr T AiSmoothStep (T e0, T e1, T t)
 RenderMan's smoothstep() function. More...
 
template<typename OUT_T , typename IN_T >
AI_DEVICE OUT_T reinterpret_type (const IN_T in)
 This function can be used to go between different interpretations of the same bits. More...
 
AI_API AI_DEVICE AI_CONST bool AiIsFinite (float x)
 Test to see if the given floating point number is finite (not NaN and not infinite) as defined by the IEEE-754 standard. More...
 
AI_API AI_CONST float AiFastExp (float x)
 Fast, approximate expf() suitable for cases where performance is more critical than accuracy. More...
 
AI_API AI_DEVICE AI_CONST float AiFastPow (float x, float y)
 Fast, approximate powf() suitable for cases where performance is more critical than accuracy. More...
 

Detailed Description

Math and comparison functions tuned for Arnold.

Function Documentation

◆ AiLinearStep()

template<typename T >
AI_DEVICE constexpr T AiLinearStep ( lo,
hi,
t 
)
inlineconstexpr

Linearly interpolated step from 'lo' to 'hi'.

Returns x where (0 <= x <= 1). Similar to AiFilterStep() but slightly different mode of calling

◆ AiSmoothStep()

template<typename T >
AI_DEVICE constexpr T AiSmoothStep ( e0,
e1,
t 
)
inlineconstexpr

RenderMan's smoothstep() function.

Returns 0 if (t < e0) or 1 if (t > e1) or a hermitian interpolation for (e0 < t < e1)

◆ reinterpret_type()

template<typename OUT_T , typename IN_T >
AI_DEVICE OUT_T reinterpret_type ( const IN_T  in)
inline

This function can be used to go between different interpretations of the same bits.

A common use case is to operate on the bits of a float as if they were an int. This should be a safe way to re-interpret bits. The alternative method of casting the address causes pointer aliasing and the results are undefined by the language. Some compilers, such as gcc, will warn about this when using -Wall and the resulting code can result in hard to debug bugs.

◆ AiIsFinite()

AI_API AI_DEVICE AI_CONST bool AiIsFinite ( float  x)

Test to see if the given floating point number is finite (not NaN and not infinite) as defined by the IEEE-754 standard.

Parameters
xfloating point value
Returns
true if the value is finite, false if NaN or infinite

◆ AiFastExp()

AI_API AI_CONST float AiFastExp ( float  x)

Fast, approximate expf() suitable for cases where performance is more critical than accuracy.

Maximum error is 392 ulp for x between [-72,72], 372 ulp between [-8,8], and 209 ulp between [0,2].

Parameters
xfloating point value between [-72,72]
Returns
exp(x) accurate to within 372 ulp

◆ AiFastPow()

AI_API AI_DEVICE AI_CONST float AiFastPow ( float  x,
float  y 
)

Fast, approximate powf() suitable for cases where performance is more critical than accuracy.

Error is only 0.00013 at pow(1.0, 2.2)

Parameters
xbase
yexponent
Returns
approximate pow(x, y)

© 2023 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com