9#ifndef MI_MATH_SPECTRUM_H
10#define MI_MATH_SPECTRUM_H
92#if defined(DEBUG) || (defined(_MSC_VER) && _MSC_VER <= 1310)
100 Float32 v = (Traits::has_signaling_NaN)
107#if (__cplusplus >= 201103L)
330 return Spectrum( lhs[0] + rhs[0], lhs[1] + rhs[1], lhs[2] + rhs[2]);
338 return Spectrum( lhs[0] - rhs[0], lhs[1] - rhs[1], lhs[2] - rhs[2]);
346 return Spectrum( lhs[0] * rhs[0], lhs[1] * rhs[1], lhs[2] * rhs[2]);
354 return Spectrum( lhs[0] / rhs[0], lhs[1] / rhs[1], lhs[2] / rhs[2]);
361 return Spectrum( -c[0], -c[1], -c[2]);
394 return Spectrum( c[0] * s, c[1] * s, c[2] * s);
401 return Spectrum( s * c[0], s * c[1], s* c[2]);
409 return Spectrum( c[0] * f, c[1] * f, c[2] * f);
434 return (c[0] != 0.0f) && (c[1] != 0.0f) && (c[2] != 0.0f);
441 return (c[0] != 0.0f) || (c[1] != 0.0f) || (c[2] != 0.0f);
482 clamp( c[1], low[1], high[1]),
483 clamp( c[2], low[2], high[2]));
492 clamp( c[1], low[1], high),
493 clamp( c[2], low[2], high));
502 clamp( c[1], low, high[1]),
503 clamp( c[2], low, high[2]));
511 clamp( c[1], low, high),
512 clamp( c[2], low, high));
642 lerp( c1[1], c2[1], t[1]),
643 lerp( c1[2], c2[2], t[2]));
657 lerp( c1[1], c2[1], t),
658 lerp( c1[2], c2[2], t));
760 sincos( a[0], s[0], c[0]);
761 sincos( a[1], s[1], c[1]);
762 sincos( a[2], s[2], c[2]);
Standard RGBA color class with floating point elements and operations.
Definition: color.h:81
Spectrum with floating point elements and operations.
Definition: spectrum.h:53
Fixed-size math vector class template with generic operations.
Definition: vector.h:286
Standard RGBA color class with floating point elements and operations.
Math functions and function templates on simple types or generic container and vector concepts.
#define MI_PREVENT_MACRO_EXPAND
Empty macro that can be used after function names to prevent macro expansion that happen to have the ...
Definition: config.h:97
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
unsigned char Uint8
8-bit unsigned integer.
Definition: types.h:47
Sint64 Difference
Signed integral type that is large enough to hold the difference of two pointers.
Definition: types.h:122
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
float Float32
32-bit float.
Definition: types.h:51
bool lexicographically_less(const V &lhs, const V &rhs)
Returns true if vector lhs is lexicographically less than vector rhs, and false otherwise.
Definition: function.h:1181
bool lexicographically_less_or_equal(const V &lhs, const V &rhs)
Returns true if vector lhs is lexicographically less than or equal to vector rhs, and false otherwise...
Definition: function.h:1197
Float32 fast_pow(Float32 b, Float32 e)
A fast implementation of pow(x,y) for floats.
Definition: function.h:403
bool lexicographically_greater_or_equal(const V &lhs, const V &rhs)
Returns true if vector lhs is lexicographically greater than or equal to vector rhs,...
Definition: function.h:1229
bool is_not_equal(const V &lhs, const V &rhs)
Returns true if vector lhs is elementwise not equal to vector rhs, and false otherwise.
Definition: function.h:1168
bool lexicographically_greater(const V &lhs, const V &rhs)
Returns true if vector lhs is lexicographically greater than vector rhs, and false otherwise.
Definition: function.h:1213
bool is_equal(const V &lhs, const V &rhs)
Returns true if vector lhs is elementwise equal to vector rhs, and false otherwise.
Definition: function.h:1157
#define mi_math_assert_msg(expr, msg)
Math API assertion macro (with message).
Definition: assert.h:80
#define mi_math_assert(expr)
Math API assertion macro (without message).
Definition: assert.h:61
bool operator>=(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is lexicographically greater than or equal to rhs.
Definition: bbox.h:652
Bbox<T, DIM> operator+(const Bbox<T, DIM> &bbox, T value)
Returns a bounding box that is the bbox increased by a constant value at each face,...
Definition: bbox.h:470
bool operator<(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is lexicographically less than rhs.
Definition: bbox.h:607
Bbox<T, DIM> & operator*=(Bbox<T, DIM> &bbox, T factor)
Scales bbox by factor, i.e., bbox.max and bbox.min are multiplied by factor.
Definition: bbox.h:564
Bbox<T, DIM> & operator+=(Bbox<T, DIM> &bbox, T value)
Increases bbox by a constant value at each face, i.e., value is added to bbox.max and subtracted from...
Definition: bbox.h:535
bool operator==(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is elementwise equal to rhs.
Definition: bbox.h:591
bool operator>(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is lexicographically greater than rhs.
Definition: bbox.h:637
Bbox<T, DIM> & operator/=(Bbox<T, DIM> &bbox, T divisor)
Divide bbox by divisor, i.e., bbox.max and bbox.min are divided by divisor.
Definition: bbox.h:578
Bbox<T, DIM> operator/(const Bbox<T, DIM> &bbox, T divisor)
Returns a bounding box that is a version of bbox divided by divisor, i.e., bbox.max and bbox....
Definition: bbox.h:518
bool operator!=(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is elementwise not equal to rhs.
Definition: bbox.h:598
bool operator<=(const Bbox<T, DIM> &lhs, const Bbox<T, DIM> &rhs)
Returns true if lhs is lexicographically less than or equal to rhs.
Definition: bbox.h:622
Bbox<T, DIM> & operator-=(Bbox<T, DIM> &bbox, T value)
Shrinks bbox by a constant value at each face, i.e., value is subtracted from bbox....
Definition: bbox.h:550
Bbox<T, DIM> operator-(const Bbox<T, DIM> &bbox, T value)
Returns a bounding box that is the bbox shrunk by a constant value at each face, i....
Definition: bbox.h:486
Bbox<T, DIM> operator*(const Bbox<T, DIM> &bbox, T factor)
Returns a bounding box that is a version of bbox scaled by factor, i.e., bbox.max and bbox....
Definition: bbox.h:502
Bbox<T, DIM> lerp(const Bbox<T, DIM> &bbox1, const Bbox<T, DIM> &bbox2, T t)
Returns the linear interpolation between bbox1 and bbox2, i.e., it returns (1-t) * bbox1 + t * bbox2.
Definition: bbox.h:672
Color frac(const Color &c)
Returns a color with the elementwise positive fractional part of the color c.
Definition: color.h:628
Color sqrt(const Color &c)
Returns the square root of each element of c.
Definition: color.h:807
bool isinfinite(const Color &c)
Indicates whether any component of the color is infinite.
Definition: color.h:834
Color acos(const Color &c)
Returns a color with the elementwise arc cosine of the color c.
Definition: color.h:480
Color ceil(const Color &c)
Returns a color with the elementwise smallest integral value that is not less than the element in col...
Definition: color.h:519
Color clamp(const Color &c, const Color &low, const Color &high)
Returns the color c elementwise clamped to the range [low, high].
Definition: color.h:525
Color abs(const Color &c)
Returns a color with the elementwise absolute values of the color c.
Definition: color.h:474
Color round(const Color &c)
Returns a color with the elements of color c rounded to nearest integers.
Definition: color.h:740
Color modf(const Color &c, Color &i)
Returns the elementwise fractional part of c and stores the elementwise integral part of c in i.
Definition: color.h:716
MI_HOST_DEVICE_INLINE void from_rgbe(const Uint8 rgbe[4], Color &color)
Decodes a color from RGBE representation.
Definition: color.h:870
Color atan(const Color &c)
Returns a color with the elementwise arc tangent of the color c.
Definition: color.h:504
bool isfinite(const Color &c)
Indicates whether all components of the color are finite.
Definition: color.h:825
Color step(const Color &a, const Color &c)
Returns elementwise 0 if c is less than a and 1 otherwise.
Definition: color.h:813
Color elementwise_min(const Color &lhs, const Color &rhs)
Returns elementwise min for each element in color lhs that is less than the corresponding element in ...
Definition: color.h:584
Color tan(const Color &c)
Returns a color with the elementwise tangent of the color c.
Definition: color.h:819
Color atan2(const Color &c, const Color &d)
Returns a color with the elementwise arc tangent of the color c / d.
Definition: color.h:512
Color sin(const Color &c)
Returns a color with the elementwise sine of the color c.
Definition: color.h:764
Color degrees(const Color &c)
Converts elementwise radians in c to degrees.
Definition: color.h:567
Color saturate(const Color &c)
Returns the color c clamped elementwise to the range [0,1].
Definition: color.h:752
Color rsqrt(const Color &c)
Returns the reciprocal of the square root of each element of c.
Definition: color.h:746
bool any(const Color &c)
Returns true if any element of c is not equal to zero.
Definition: color.h:492
Color radians(const Color &c)
Converts elementwise degrees in c to radians.
Definition: color.h:734
Color exp2(const Color &c)
Returns a color with elementwise 2 to the power of the element in the color c.
Definition: color.h:599
Color elementwise_max(const Color &lhs, const Color &rhs)
Returns elementwise max for each element in color lhs that is less than the corresponding element in ...
Definition: color.h:574
Color log(const Color &c)
Returns a color with elementwise natural logarithm of the color c.
Definition: color.h:692
Color floor(const Color &c)
Returns a color with the elementwise largest integral value that is not greater than the element in c...
Definition: color.h:606
Color smoothstep(const Color &a, const Color &b, const Color &c)
Returns 0 if c is less than a and 1 if c is greater than b in an elementwise fashion.
Definition: color.h:785
Color sign(const Color &c)
Returns the elementwise sign of color c.
Definition: color.h:758
Color fmod(const Color &a, const Color &b)
Returns elementwise a modulo b, in other words, the remainder of a/b.
Definition: color.h:614
Color cos(const Color &c)
Returns a color with the elementwise cosine of the color c.
Definition: color.h:561
MI_HOST_DEVICE_INLINE void to_rgbe(const Color &color, Uint32 &rgbe)
Encodes a color into RGBE representation.
Definition: color.h:854
Color pow(const Color &a, const Color &b)
Returns the color a elementwise to the power of b.
Definition: color.h:722
Float32 c[3]
Three color bands.
Definition: color.h:49
bool all(const Color &c)
Returns true if all elements of c are not equal to zero.
Definition: color.h:486
bool isnan(const Color &c)
Indicates whether any component of the color is "not a number".
Definition: color.h:843
Color gamma_correction(const Color &color, Float32 gamma_factor)
Returns a gamma corrected color.
Definition: color.h:640
Color log10(const Color &c)
Returns a color with elementwise base 10 logarithm of the color c.
Definition: color.h:707
Color log2(const Color &c)
Returns a color with elementwise base 2 logarithm of the color c.
Definition: color.h:698
Color exp(const Color &c)
Returns a color with elementwise e to the power of the element in the color c.
Definition: color.h:593
bool is_approx_equal(const Color &lhs, const Color &rhs, Float32 e)
Compares the two given values elementwise for equality within the given epsilon.
Definition: color.h:653
void sincos(const Color &a, Color &s, Color &c)
Computes elementwise the sine s and cosine c of angles a simultaneously.
Definition: color.h:772
Color asin(const Color &c)
Returns a color with the elementwise arc sine of the color c.
Definition: color.h:498
Float32 * end()
Returns the past-the-end pointer.
Definition: spectrum.h:82
Size size_type
Size type, unsigned.
Definition: spectrum.h:58
Spectrum & operator=(const Spectrum &s)=default
Default assignment operator.
const Float32 * const_pointer
Const pointer to element.
Definition: spectrum.h:61
Float32 linear_intensity() const
Returns the intensity of the RGB components, equally weighted.
Definition: spectrum.h:222
const Float32 & const_reference
Const reference to element.
Definition: spectrum.h:63
MI_HOST_DEVICE_INLINE const Float32 & operator[](Size i) const
Accesses the i-th spectrum element, 0 <= i < 3.
Definition: spectrum.h:184
const Float32 * begin() const
Returns the pointer to the first spectrum element.
Definition: spectrum.h:77
Float32 & reference
Mutable reference to element.
Definition: spectrum.h:62
Vector<Float32, 4> to_vector4() const
Conversion to Vector<Float32,4>.
Definition: spectrum.h:173
const Float32 * end() const
Returns the past-the-end pointer.
Definition: spectrum.h:87
Vector<Float32, 3> to_vector3() const
Conversion to Vector<Float32,3>.
Definition: spectrum.h:163
static Size size()
Constant size of the spectrum.
Definition: spectrum.h:68
Spectrum(const Vector<Float32, 3> &v3)
Conversion from Vector<Float32,3>.
Definition: spectrum.h:139
Spectrum()
The default constructor leaves the spectrum elements uninitialized.
Definition: spectrum.h:90
Spectrum(Float32 nr, Float32 ng, Float32 nb)
Constructor initializes (r,g,b) from (nr,ng,nb).
Definition: spectrum.h:131
Spectrum_struct Pod_type
POD class corresponding to this spectrum.
Definition: spectrum.h:55
bool is_black() const
Returns true if the spectrum is black ignoring the alpha value.
Definition: spectrum.h:213
Float32 * pointer
Mutable pointer to element.
Definition: spectrum.h:60
Spectrum_struct storage_type
Storage class used by this spectrum.
Definition: spectrum.h:56
Difference difference_type
Difference type, signed.
Definition: spectrum.h:59
void set(Size i, Float32 value)
Sets the i-th spectrum element to value, 0 <= i < 3.
Definition: spectrum.h:206
Spectrum(const Color &col)
Conversion from Color.
Definition: spectrum.h:155
Spectrum(const Vector<Float32, 4> &v4)
Conversion from Vector<Float32,4>.
Definition: spectrum.h:147
Spectrum(const Spectrum_struct &s)
Constructor from underlying storage type.
Definition: spectrum.h:116
Spectrum(const Float32 s)
Constructor initializes all vector elements to the value s.
Definition: spectrum.h:124
Float32 * begin()
Returns the pointer to the first spectrum element.
Definition: spectrum.h:74
Float32 get(Size i) const
Returns the i-th spectrum element, 0 <= i < 3.
Definition: spectrum.h:199
Spectrum(const Spectrum &s)=default
Default copy constructor.
static const Size SIZE
Constant size of the spectrum.
Definition: spectrum.h:65
static Size max_size()
Constant maximum size of the spectrum.
Definition: spectrum.h:71
Float32 value_type
Element type.
Definition: spectrum.h:57
Float32 g
Green color component.
Definition: vector.h:71
Float32 r
Red color component.
Definition: vector.h:69
Float32 b
Blue color component.
Definition: vector.h:73
math::Spectrum Spectrum
Spectrum class.
Definition: typedefs.h:47
Assertions and compile-time assertions.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: dice.h:89
Numeric traits specialization for mi::Float32.
Definition: types.h:531
Generic storage class template for a Spectrum representation storing three floating point elements.
Definition: color.h:47
Math vector class template of fixed dimension with arithmetic operators and generic functions.