10#ifndef MI_MATH_VECTOR_H
11#define MI_MATH_VECTOR_H
133template <
typename T, Size DIM>
173template <
typename T, Size DIM>
180template <
typename T, Size DIM>
284template <
class T, Size DIM>
322 inline const T*
end()
const {
return begin() + DIM; }
327#if defined(DEBUG) || (defined(_MSC_VER) && _MSC_VER <= 1310)
335 T v = (Traits::has_signaling_NaN) ? Traits::signaling_NaN()
337 for(
Size i(0u); i < DIM; ++i)
342#if (__cplusplus >= 201103L)
350 for(
Size i(0u); i < DIM; ++i)
357 for(
Size i(0u); i < DIM; ++i)
374 template <
typename Iterator>
377 for(
Size i(0u); i < DIM; ++i, ++p)
392 template <
typename T2>
393 inline explicit Vector( T2
const (& array)[DIM])
395 for(
Size i(0u); i < DIM; ++i)
396 (*
this)[i] = array[i];
401 template <
typename T2>
404 for(
Size i(0u); i < DIM; ++i)
405 (*
this)[i] = T(other[i]);
410 template <
typename T2>
413 for(
Size i(0u); i < DIM; ++i)
570#if (__cplusplus >= 201103L)
575 for(
Size i(0u); i < DIM; ++i)
576 (*
this)[i] = other[i];
584 for(
Size i(0u); i < DIM; ++i)
648 const T rec_length = T(1) /
length( *
this);
649 const bool result =
isfinite( rec_length);
651 (*this) *= rec_length;
707template <
typename T, Size DIM>
712 for(
Size i(0u); i < DIM; ++i)
718template <
typename T, Size DIM>
723 for(
Size i(0u); i < DIM; ++i)
729template <
typename T, Size DIM>
734 for(
Size i(0u); i < DIM; ++i)
741template <
typename T, Size DIM>
746 for(
Size i(0u); i < DIM; ++i)
752template <
typename T,
typename U, Size DIM>
757 for(
Size i(0u); i < DIM; ++i)
763template <
typename T, Size DIM>
773template <
typename T, Size DIM>
783template <
typename T, Size DIM>
794template <
typename T, Size DIM>
804template <
typename T,
typename U, Size DIM>
814template <
typename T, Size DIM>
818 for(
Size i(0u); i < DIM; ++i)
829template <
typename T, Size DIM>
838template <
typename T, Size DIM>
847template <
typename T, Size DIM>
857template <
typename T, Size DIM>
866template <
typename T,
typename U, Size DIM>
875template <
typename T, Size DIM>
884template <
typename T, Size DIM>
893template <
typename T, Size DIM>
903template <
typename T, Size DIM>
912template <
typename T,
typename U, Size DIM>
921template <
typename T, Size DIM>
932template <
typename T,
typename TT, Size DIM>
937 for(
Size i(0u); i < DIM; ++i)
945template <
typename T,
typename TT, Size DIM>
950 for(
Size i(0u); i < DIM; ++i)
956template <
typename T,
typename TT, Size DIM>
961 for(
Size i(0u); i < DIM; ++i)
967template <
typename T,
typename TT, Size DIM>
977template <
typename T,
typename TT, Size DIM>
989template <
typename T,
typename TT, Size DIM>
999template <
typename T,
typename TT, Size DIM>
1012template <
typename T, Size DIM>
1020template <
typename T, Size DIM>
1143template <
typename T, Size DIM>
1154template <
typename T, Size DIM>
1165template <
typename T, Size DIM>
1176template <
typename T, Size DIM>
1187template <
typename T, Size DIM>
1198template <
typename T, Size DIM>
1212template <
typename T, Size DIM>
1216 for(
Size i = 0; i != DIM; ++i)
1222template <
typename T, Size DIM>
1226 for(
Size i = 0; i != DIM; ++i)
1232template <
typename T, Size DIM>
1235 for(
Size i = 0; i != DIM; ++i)
1242template <
typename T, Size DIM>
1245 for(
Size i = 0; i != DIM; ++i)
1252template <
typename T, Size DIM>
1256 for(
Size i = 0; i != DIM; ++i)
1262template <
typename T, Size DIM>
1266 for(
Size i = 0; i != DIM; ++i)
1274template <
typename T, Size DIM>
1278 for(
Size i = 0; i != DIM; ++i)
1285template <
typename T, Size DIM>
1289 for(
Size i = 0; i != DIM; ++i)
1295template <
typename T, Size DIM>
1302 for(
Size i = 0u; i < DIM; ++i)
1309template <
typename T, Size DIM>
1316 for(
Size i = 0u; i < DIM; ++i)
1322template <
typename T, Size DIM>
1329 for(
Size i = 0u; i < DIM; ++i)
1335template <
typename T, Size DIM>
1342 for(
Size i = 0u; i < DIM; ++i)
1348template <
typename T, Size DIM>
1352 for(
Size i = 0; i != DIM; ++i)
1358template <
typename T, Size DIM>
1362 for(
Size i = 0; i != DIM; ++i)
1368template <
typename T, Size DIM>
1374 for(
Size i(0u); i < Vector<T,DIM>::DIMENSION; ++i)
1381template <
typename T, Size DIM>
1387 for(
Size i(0u); i < Vector<T,DIM>::DIMENSION; ++i)
1394template <
typename T, Size DIM>
1398 for(
Size i = 0; i != DIM; ++i)
1404template <
typename T, Size DIM>
1408 for(
Size i = 0; i != DIM; ++i)
1415template <
typename T, Size DIM>
1419 for(
Size i = 0; i != DIM; ++i)
1427template <
typename T, Size DIM>
1431 for(
Size i = 0; i != DIM; ++i)
1439template <
typename T, Size DIM>
1443 for(
Size i = 0; i != DIM; ++i)
1449template <
typename T, Size DIM>
1453 for(
Size i = 0; i != DIM; ++i)
1459template <
typename T, Size DIM>
1465 for(
Size i = 0u; i < DIM; ++i)
1473template <
typename T, Size DIM>
1480 for(
Size i = 0; i != DIM; ++i)
1488template <
typename T, Size DIM>
1497 for(
Size i = 0; i != DIM; ++i)
1503template <
typename T, Size DIM>
1507 for(
Size i = 0; i != DIM; ++i)
1513template <
typename T, Size DIM>
1517 for(
Size i = 0; i != DIM; ++i)
1523template <
typename T, Size DIM>
1527 for(
Size i = 0; i != DIM; ++i)
1536template <
typename T, Size DIM>
1540 for(
Size j = 0; j != DIM; ++j)
1546template <
typename T, Size DIM>
1550 for(
Size i = 0; i != DIM; ++i)
1556template <
typename T, Size DIM>
1560 for(
Size i = 0; i != DIM; ++i)
1566template <
typename T, Size DIM>
1570 for(
Size i = 0; i != DIM; ++i)
1576template <
typename T, Size DIM>
1580 for(
Size i = 0; i != DIM; ++i)
1586template <
typename T, Size DIM>
1590 for(
Size i = 0; i != DIM; ++i)
1596template <
typename T, Size DIM>
1600 for(
Size i = 0; i != DIM; ++i)
1606template <
typename T, Size DIM>
1610 for(
Size i = 0; i != DIM; ++i)
1616template <
typename T, Size DIM>
1620 for(
Size i = 0; i != DIM; ++i)
1628template <
typename T, Size DIM>
1631 for(
Size i = 0; i != DIM; ++i)
1640template <
typename T, Size DIM>
1647 for(
Size i = 0; i != DIM; ++i)
1658template <
typename T, Size DIM>
1665 for(
Size i = 0; i != DIM; ++i)
1671template <
typename T, Size DIM>
1675 for(
Size i = 0; i != DIM; ++i)
1681template <
typename T, Size DIM>
1685 for(
Size i = 0; i != DIM; ++i)
1691template <
typename T, Size DIM>
1695 for(
Size i = 0; i != DIM; ++i)
1704template <
typename T>
1709 return lhs.
x * rhs.
y - lhs.
y * rhs.
x;
1713template <
typename T>
1719 lhs.
z * rhs.
x - lhs.
x * rhs.
z,
1720 lhs.
x * rhs.
y - lhs.
y * rhs.
x);
1728template <
typename T>
1734#ifdef mi_base_assert_enabled
1735 const T eps = 1e-6f;
1744 if(
abs(n.x) <
abs(n.y)) {
1776template <
typename T>
1784 const T eps = 1e-6f;
1806 if(
dot( *b,v) < T(0))
1826template <
typename T2, Size DIM2,
typename T1, Size DIM1>
1829 const T2& fill = T2(0))
1833 for(
Size i = 0; i < dim_min; ++i)
1834 result[i] = T2(v[i]);
1835 for(
Size i = dim_min; i < DIM2; ++i)
Fixed-size math vector class template with generic operations.
Definition: vector.h:286
Math functions and function templates on simple types or generic container and vector concepts.
#define mi_static_assert(expr)
Compile time assertion that raises a compilation error if the constant expression expr evaluates to f...
Definition: assert.h:65
#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
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
Sint32 dot(Sint32 a, Sint32 b)
Returns the inner product (a.k.a. dot or scalar product) of two integers.
Definition: function.h:1088
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
Float32 length(Float32 a)
Returns the Euclidean norm of the scalar a (its absolute value).
Definition: function.h:1114
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
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
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
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
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
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
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
Color pow(const Color &a, const Color &b)
Returns the color a elementwise to the power of b.
Definition: color.h:722
bool all(const Color &c)
Returns true if all elements of c are not equal to zero.
Definition: color.h:486
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
void transform(const Vector &vec, ResultVector &result, UnaryFunctor f)
Generic transform function that applies a unary functor (return value).
Definition: function.h:234
void for_each(Vector &vec, UnaryFunctor f)
Generic transform function that applies a unary functor (in-place).
Definition: function.h:302
void transform_right_scalar(const Vector &vec, const Scalar &s, ResultVector &result, BinaryFunctor f)
Generic transform function that applies a binary functor (return value, RHS scalar).
Definition: function.h:287
void transform_left_scalar(const Scalar &s, const Vector &vec, ResultVector &result, BinaryFunctor f)
Generic transform function that applies a binary functor (return value, LHS scalar).
Definition: function.h:269
Difference difference_type
Difference type, signed.
Definition: vector.h:293
T y
y-coordinate.
Definition: vector.h:164
Vector(const Vector<T2, DIM> &other)
Template constructor that allows explicit conversions from other vectors with assignment compatible e...
Definition: vector.h:402
Vector<bool, DIM> operator^(const Vector<bool, DIM> &lhs, const Vector<bool, DIM> &rhs)
Returns the elementwise logical xor of two boolean vectors.
Definition: vector.h:1098
T & reference
Mutable reference to element.
Definition: vector.h:296
void set(Size i, T value)
Sets the i-th vector element to value.
Definition: vector.h:632
Vector(T2 const (&array)[DIM])
Constructor initializes the vector elements from an array of dimension DIM.
Definition: vector.h:393
T x
x-coordinate.
Definition: vector.h:163
T cross(const Vector_struct<T, 2> &lhs, const Vector_struct<T, 2> &rhs)
Returns the two-times-two determinant result for the two vectors lhs and rhs.
Definition: vector.h:1705
Vector(T v1, const Vector<T, 3> &v2)
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four eleme...
Definition: vector.h:534
const T * end() const
Returns the past-the-end pointer.
Definition: vector.h:322
T elements[DIM]
coordinates.
Definition: vector.h:136
T w
w-coordinate.
Definition: vector.h:166
Vector_struct<T, DIM> storage_type
Storage class used by this vector.
Definition: vector.h:289
const T & const_reference
Const reference to element.
Definition: vector.h:297
Vector<bool, DIM> elementwise_is_greater_than(const Vector<T, DIM> &lhs, const Vector<T, DIM> &rhs)
Returns the boolean vector result of an elementwise greater-than comparison.
Definition: vector.h:1188
Vector(const Color_struct &color)
Dedicated constructor, for dimension 4 only, that initializes the vector elements from a color interp...
Definition: vector.h:560
Vector<bool, DIM> elementwise_is_greater_than_or_equal(const Vector<T, DIM> &lhs, const Vector<T, DIM> &rhs)
Returns the boolean vector result of an elementwise greater-than-or-equal comparison.
Definition: vector.h:1199
Vector_struct<T, DIM> Pod_type
POD class corresponding to this vector.
Definition: vector.h:288
Float32 g
Green color component.
Definition: vector.h:71
Vector(const Vector<T, 2> &v1, const Vector<T, 2> &v2)
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four eleme...
Definition: vector.h:521
Vector(From_iterator_tag, Iterator p)
Constructor requires the mi::math::FROM_ITERATOR tag as first argument and initializes the vector ele...
Definition: vector.h:375
bool operator<=(Vector<T, DIM> rhs) const
Returns true if lhs is lexicographically less than or equal to rhs.
Definition: vector.h:681
Vector(const Vector<T, 3> &v1, T v2)
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four eleme...
Definition: vector.h:547
bool operator>=(Vector<T, DIM> rhs) const
Returns true if lhs is lexicographically greater than or equal to rhs.
Definition: vector.h:697
const T * const_pointer
Const pointer to element.
Definition: vector.h:295
bool operator>(Vector<T, DIM> rhs) const
Returns true if lhs is lexicographically greater than rhs.
Definition: vector.h:689
Vector(const Vector_struct<T, DIM> &vec)
Constructor from underlying storage type.
Definition: vector.h:348
Vector<T, DIM> & operator++(Vector<T, DIM> &vec)
Pre-increments all elements of vec and returns the result. Modifies vec.
Definition: vector.h:1013
Vector<T, DIM> & operator--(Vector<T, DIM> &vec)
Pre-decrements all elements of vec and returns the result. Modifies vec.
Definition: vector.h:1021
Vector(const Vector<T, 2> &v1, T v2)
Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elem...
Definition: vector.h:456
Vector(T v)
Constructor initializes all vector elements to the value v.
Definition: vector.h:355
Vector<bool, DIM> elementwise_is_not_equal(const Vector<T, DIM> &lhs, const Vector<T, DIM> &rhs)
Returns the boolean vector result of an elementwise inequality comparison.
Definition: vector.h:1155
Vector(T v1, T v2, T v3, T v4)
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four eleme...
Definition: vector.h:468
T & operator[](Size i)
Accesses the i-th vector element.
Definition: vector.h:605
const T * begin() const
Returns the pointer to the first vector element.
Definition: vector.h:312
Vector(const Vector_struct<T2, DIM> &other)
Template constructor that allows explicit conversions from underlying storage type with assignment co...
Definition: vector.h:411
static Size max_size()
Constant maximum size of the vector.
Definition: vector.h:306
Vector<T2, DIM2> convert_vector(const Vector<T1, DIM1> &v, const T2 &fill=T2(0))
Converts the vector v of type Vector<T1, DIM1> to a vector of type Vector<T2, DIM2>.
Definition: vector.h:1827
const T & get(Size i) const
Returns the i-th vector element.
Definition: vector.h:623
T x
x-coordinate.
Definition: vector.h:148
Vector<T, DIM> & operator%=(Vector<T, DIM> &lhs, const Vector_struct<T, DIM> &rhs)
Computes lhs modulo rhs elementwise and returns the modified lhs.
Definition: vector.h:742
T value_type
Element type.
Definition: vector.h:291
Size size_type
Size type, unsigned.
Definition: vector.h:292
T * vector_base_ptr(Vector_struct<T, DIM> &vec)
Returns the base pointer to the vector data.
Definition: vector.h:174
Vector(const Vector<T, DIM> &vec)=default
Default copy constructor.
static Size size()
Constant size of the vector.
Definition: vector.h:303
Vector(T v1, T v2, const Vector<T, 2> &v3)
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four eleme...
Definition: vector.h:481
Vector & operator=(const Vector &other)=default
Assignment.
Vector()
The default constructor leaves the vector elements uninitialized.
Definition: vector.h:325
T y
y-coordinate.
Definition: vector.h:156
bool operator==(Vector<T, DIM> rhs) const
Returns true if lhs is elementwise equal to rhs.
Definition: vector.h:659
static const Size SIZE
Constant size of the vector.
Definition: vector.h:300
Vector(const Vector<T, 2> &v1, T v2, T v3)
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four eleme...
Definition: vector.h:508
T z
z-coordinate.
Definition: vector.h:165
Vector<bool, DIM> elementwise_is_less_than_or_equal(const Vector<T, DIM> &lhs, const Vector<T, DIM> &rhs)
Returns the boolean vector result of an elementwise less-than-or-equal comparison.
Definition: vector.h:1177
T z
z-coordinate.
Definition: vector.h:157
Float32 a
Alpha value, 0.0 is fully transparent and 1.0 is opaque; value can lie outside that range.
Definition: vector.h:75
Vector(T v1, T v2, T v3)
Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elem...
Definition: vector.h:432
Vector<T, DIM> operator%(const Vector_struct<T, DIM> &lhs, const Vector_struct<T, DIM> &rhs)
Computes lhs modulo rhs elementwise and returns the new result.
Definition: vector.h:795
Float32 r
Red color component.
Definition: vector.h:69
bool normalize()
Normalizes this vector to unit length.
Definition: vector.h:646
Vector<bool, DIM> operator&&(const Vector<bool, DIM> &lhs, const Vector<bool, DIM> &rhs)
Returns the elementwise logical and of two boolean vectors.
Definition: vector.h:1032
T * end()
Returns the past-the-end pointer.
Definition: vector.h:317
Vector<bool, DIM> operator!(const Vector<bool, DIM> &vec)
Returns the elementwise logical not of a boolean vector.
Definition: vector.h:1131
bool operator<(Vector<T, DIM> rhs) const
Returns true if lhs is lexicographically less than rhs.
Definition: vector.h:673
T y
y-coordinate.
Definition: vector.h:149
T * begin()
Returns the pointer to the first vector element.
Definition: vector.h:309
Vector<bool, DIM> operator||(const Vector<bool, DIM> &lhs, const Vector<bool, DIM> &rhs)
Returns the elementwise logical or of two boolean vectors.
Definition: vector.h:1065
T x
x-coordinate.
Definition: vector.h:155
Float32 b
Blue color component.
Definition: vector.h:73
Vector(T v1, T v2)
Dedicated constructor, for dimension 2 only, that initializes the vector elements from the two elemen...
Definition: vector.h:421
Vector<bool, DIM> elementwise_is_equal(const Vector<T, DIM> &lhs, const Vector<T, DIM> &rhs)
Returns the boolean vector result of an elementwise equality comparison.
Definition: vector.h:1144
T * pointer
Mutable pointer to element.
Definition: vector.h:294
Vector(T v1, const Vector<T, 2> &v2)
Dedicated constructor, for dimension 3 only, that initializes the vector elements from the three elem...
Definition: vector.h:444
void make_basis(const Vector<T, 3> &n, Vector<T, 3> *u, Vector<T, 3> *v)
Computes a basis of 3D space with one given vector.
Definition: vector.h:1729
Vector<bool, DIM> elementwise_is_less_than(const Vector<T, DIM> &lhs, const Vector<T, DIM> &rhs)
Returns the boolean vector result of an elementwise less-than comparison.
Definition: vector.h:1166
bool operator!=(Vector<T, DIM> rhs) const
Returns true if lhs is elementwise not equal to rhs.
Definition: vector.h:665
T x
x-coordinate.
Definition: vector.h:142
static const Size DIMENSION
Constant dimension of the vector.
Definition: vector.h:299
Vector(T v1, const Vector<T, 2> &v2, T v3)
Dedicated constructor, for dimension 4 only, that initializes the vector elements from the four eleme...
Definition: vector.h:495
From_iterator_tag
Enum used for initializing a vector from an iterator.
Definition: vector.h:36
@ FROM_ITERATOR
Unique enumerator of From_iterator_tag.
Definition: vector.h:37
Assertions and compile-time assertions.
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: math.h:22
Helper class to deduce properties of numeric types defined in this API.
Definition: types.h:428
Generic storage class template for an RGBA color representation storing four floating points elements...
Definition: vector.h:67
Specialization for dimension 1 to create x member.
Definition: vector.h:141
Specialization for dimension 2 to create x and y member.
Definition: vector.h:147
Specialization for dimension 3 to create x, y, and z members.
Definition: vector.h:154
Specialization for dimension 4 to create x, y, z, and w members.
Definition: vector.h:162
Generic storage class template for math vector representations storing DIM elements of type T.
Definition: vector.h:135
Functor for the logical and operator, &&.
Definition: function.h:149
Functor for the equality comparison operator, ==.
Definition: function.h:76
Functor for the greater-than-or-equal comparison operator, >=.
Definition: function.h:111
Functor for the greater-than comparison operator, >.
Definition: function.h:104
Functor for the less-than-or-equal comparison operator, <=.
Definition: function.h:97
Functor for the less-than comparison operator, <.
Definition: function.h:90
Functor for the inequality comparison operator, !=.
Definition: function.h:83
Functor for the logical not operator, !.
Definition: function.h:170
Functor for the logical or operator, ||.
Definition: function.h:156
Functor for the pre-decrement operator, --.
Definition: function.h:191
Functor for the pre-increment operator, ++.
Definition: function.h:177
Functor for the xor operator, ^.
Definition: function.h:163