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; }
332 T v = (Traits::has_signaling_NaN) ? Traits::signaling_NaN()
334 for(
Size i(0u); i < DIM; ++i)
345 for(
Size i(0u); i < DIM; ++i)
349#if (__cplusplus >= 201402L)
352 constexpr inline void init( std::integral_constant<Size,s>, T v)
354 for(
Size i = 0; i < DIM; ++i)
358 constexpr inline void init( std::integral_constant<Size,1>, T v)
361 constexpr inline void init( std::integral_constant<Size,2>, T v)
362 { Pod_type::x = Pod_type::y = v; }
364 constexpr inline void init( std::integral_constant<Size,3>, T v)
365 { Pod_type::x = Pod_type::y = Pod_type::z = v; }
367 constexpr inline void init( std::integral_constant<Size,4>, T v)
368 { Pod_type::x = Pod_type::y = Pod_type::z = Pod_type::w = v; }
372 constexpr inline explicit Vector(T v)
374 init( std::integral_constant<Size,DIM>(), v);
377 inline explicit Vector(T v)
379 for(
Size i(0u); i < DIM; ++i)
397 template <
typename Iterator>
400 for(
Size i(0u); i < DIM; ++i, ++p)
415 template <
typename T2>
416 inline explicit Vector( T2
const (& array)[DIM])
418 for(
Size i(0u); i < DIM; ++i)
419 begin()[i] = array[i];
424 template <
typename T2>
427 for(
Size i(0u); i < DIM; ++i)
428 begin()[i] = T(other[i]);
433 template <
typename T2>
436 for(
Size i(0u); i < DIM; ++i)
444#if (__cplusplus >= 201402L)
456#if (__cplusplus >= 201402L)
468#if (__cplusplus >= 201402L)
480#if (__cplusplus >= 201402L)
492#if (__cplusplus >= 201402L)
504#if (__cplusplus >= 201402L)
516#if (__cplusplus >= 201402L)
528#if (__cplusplus >= 201402L)
540#if (__cplusplus >= 201402L)
552#if (__cplusplus >= 201402L)
564#if (__cplusplus >= 201402L)
576#if (__cplusplus >= 201402L)
588#if (__cplusplus >= 201402L)
593#if (__cplusplus >= 201402L)
594 init(std::integral_constant<Size,DIM>(), s);
596 for(
Size i(0u); i < DIM; ++i)
605#if (__cplusplus >= 201402L)
611 Pod_type::x = color.
r;
612 Pod_type::y = color.
g;
613 Pod_type::z = color.
b;
614 Pod_type::w = color.
a;
664 const T rec_length = T(1) /
length( *
this);
665 const bool result =
isfinite( rec_length);
667 (*this) *= rec_length;
723template <
typename T, Size DIM>
728 for(
Size i(0u); i < DIM; ++i)
735 const Vector_struct<T,1>& rhs)
743 const Vector_struct<T,2>& rhs)
752 const Vector_struct<T,3>& rhs)
762 const Vector_struct<T,4>& rhs)
772template <
typename T, Size DIM>
777 for(
Size i(0u); i < DIM; ++i)
784 const Vector_struct<T,1>& rhs)
792 const Vector_struct<T,2>& rhs)
801 const Vector_struct<T,3>& rhs)
811 const Vector_struct<T,4>& rhs)
821template <
typename T, Size DIM>
826 for(
Size i(0u); i < DIM; ++i)
833 const Vector_struct<T,1>& rhs)
841 const Vector_struct<T,2>& rhs)
850 const Vector_struct<T,3>& rhs)
860 const Vector_struct<T,4>& rhs)
871template <
typename T, Size DIM>
876 for(
Size i(0u); i < DIM; ++i)
882template <
typename T,
typename U, Size DIM>
887 for(
Size i(0u); i < DIM; ++i)
893template <
typename T, Size DIM>
903template <
typename T, Size DIM>
913template <
typename T, Size DIM>
924template <
typename T, Size DIM>
934template <
typename T,
typename U, Size DIM>
944template <
typename T, Size DIM>
948 for(
Size i(0u); i < DIM; ++i)
953inline Vector<T,1>
operator-(
const Vector_struct<T,1>& v)
955 return Vector<T,1>( -v.x);
958inline Vector<T,2>
operator-(
const Vector_struct<T,2>& v)
960 return Vector<T,2>( -v.x, -v.y);
963inline Vector<T,3>
operator-(
const Vector_struct<T,3>& v)
965 return Vector<T,3>( -v.x, -v.y, -v.z);
968inline Vector<T,4>
operator-(
const Vector_struct<T,4>& v)
970 return Vector<T,4>( -v.x, -v.y, -v.z, -v.w);
979template <
typename T, Size DIM>
988template <
typename T, Size DIM>
997template <
typename T, Size DIM>
1004template <
typename T>
1007 const Vector<T,1>& rhs)
1009 return lhs *=
static_cast<const Vector_struct<T,1>&
>(rhs);
1011template <
typename T>
1014 const Vector<T,2>& rhs)
1016 return lhs *=
static_cast<const Vector_struct<T,2>&
>(rhs);
1018template <
typename T>
1021 const Vector<T,3>& rhs)
1023 return lhs *=
static_cast<const Vector_struct<T,3>&
>(rhs);
1025template <
typename T>
1028 const Vector<T,4>& rhs)
1030 return lhs *=
static_cast<const Vector_struct<T,4>&
>(rhs);
1035template <
typename T, Size DIM>
1044template <
typename T,
typename U, Size DIM>
1053template <
typename T, Size DIM>
1062template <
typename T, Size DIM>
1071template <
typename T, Size DIM>
1081template <
typename T, Size DIM>
1090template <
typename T,
typename U, Size DIM>
1099template <
typename T, Size DIM>
1110template <
typename T,
typename TT, Size DIM>
1115 for(
Size i(0u); i < DIM; ++i)
1119template <
typename T,
typename TT>
1127template <
typename T,
typename TT>
1136template <
typename T,
typename TT>
1146template <
typename T,
typename TT>
1161template <
typename T,
typename TT, Size DIM>
1166 for(
Size i(0u); i < DIM; ++i)
1172template <
typename T,
typename TT, Size DIM>
1177 for(
Size i(0u); i < DIM; ++i)
1183template <
typename T,
typename TT, Size DIM>
1193template <
typename T,
typename TT, Size DIM>
1205template <
typename T,
typename TT, Size DIM>
1215template <
typename T,
typename TT, Size DIM>
1228template <
typename T, Size DIM>
1236template <
typename T, Size DIM>
1359template <
typename T, Size DIM>
1370template <
typename T, Size DIM>
1381template <
typename T, Size DIM>
1392template <
typename T, Size DIM>
1403template <
typename T, Size DIM>
1414template <
typename T, Size DIM>
1428template <
typename T, Size DIM>
1432 for(
Size i = 0; i != DIM; ++i)
1438template <
typename T, Size DIM>
1442 for(
Size i = 0; i != DIM; ++i)
1448template <
typename T, Size DIM>
1451 for(
Size i = 0; i != DIM; ++i)
1458template <
typename T, Size DIM>
1461 for(
Size i = 0; i != DIM; ++i)
1468template <
typename T, Size DIM>
1472 for(
Size i = 0; i != DIM; ++i)
1478template <
typename T, Size DIM>
1482 for(
Size i = 0; i != DIM; ++i)
1490template <
typename T, Size DIM>
1494 for(
Size i = 0; i != DIM; ++i)
1501template <
typename T, Size DIM>
1505 for(
Size i = 0; i != DIM; ++i)
1511template <
typename T, Size DIM>
1518 for(
Size i = 0u; i < DIM; ++i)
1525template <
typename T, Size DIM>
1532 for(
Size i = 0u; i < DIM; ++i)
1538template <
typename T, Size DIM>
1545 for(
Size i = 0u; i < DIM; ++i)
1551template <
typename T, Size DIM>
1558 for(
Size i = 0u; i < DIM; ++i)
1564template <
typename T, Size DIM>
1568 for(
Size i = 0; i != DIM; ++i)
1574template <
typename T, Size DIM>
1578 for(
Size i = 0; i != DIM; ++i)
1584template <
typename T, Size DIM>
1590 for(
Size i(0u); i < Vector<T,DIM>::DIMENSION; ++i)
1597template <
typename T, Size DIM>
1603 for(
Size i(0u); i < Vector<T,DIM>::DIMENSION; ++i)
1610template <
typename T, Size DIM>
1614 for(
Size i = 0; i != DIM; ++i)
1620template <
typename T, Size DIM>
1624 for(
Size i = 0; i != DIM; ++i)
1631template <
typename T, Size DIM>
1635 for(
Size i = 0; i != DIM; ++i)
1643template <
typename T, Size DIM>
1647 for(
Size i = 0; i != DIM; ++i)
1655template <
typename T, Size DIM>
1659 for(
Size i = 0; i != DIM; ++i)
1665template <
typename T, Size DIM>
1669 for(
Size i = 0; i != DIM; ++i)
1675template <
typename T, Size DIM>
1681 for(
Size i = 0u; i < DIM; ++i)
1689template <
typename T, Size DIM>
1696 for(
Size i = 0; i != DIM; ++i)
1704template <
typename T, Size DIM>
1713 for(
Size i = 0; i != DIM; ++i)
1719template <
typename T, Size DIM>
1723 for(
Size i = 0; i != DIM; ++i)
1729template <
typename T, Size DIM>
1733 for(
Size i = 0; i != DIM; ++i)
1739template <
typename T, Size DIM>
1743 for(
Size i = 0; i != DIM; ++i)
1752template <
typename T, Size DIM>
1756 for(
Size j = 0; j != DIM; ++j)
1762template <
typename T, Size DIM>
1766 for(
Size i = 0; i != DIM; ++i)
1772template <
typename T, Size DIM>
1776 for(
Size i = 0; i != DIM; ++i)
1782template <
typename T, Size DIM>
1786 for(
Size i = 0; i != DIM; ++i)
1792template <
typename T, Size DIM>
1796 for(
Size i = 0; i != DIM; ++i)
1802template <
typename T, Size DIM>
1806 for(
Size i = 0; i != DIM; ++i)
1812template <
typename T, Size DIM>
1816 for(
Size i = 0; i != DIM; ++i)
1822template <
typename T, Size DIM>
1826 for(
Size i = 0; i != DIM; ++i)
1832template <
typename T, Size DIM>
1836 for(
Size i = 0; i != DIM; ++i)
1844template <
typename T, Size DIM>
1847 for(
Size i = 0; i != DIM; ++i)
1856template <
typename T, Size DIM>
1863 for(
Size i = 0; i != DIM; ++i)
1874template <
typename T, Size DIM>
1881 for(
Size i = 0; i != DIM; ++i)
1887template <
typename T, Size DIM>
1891 for(
Size i = 0; i != DIM; ++i)
1897template <
typename T, Size DIM>
1901 for(
Size i = 0; i != DIM; ++i)
1907template <
typename T, Size DIM>
1911 for(
Size i = 0; i != DIM; ++i)
1920template <
typename T>
1925 return lhs.
x * rhs.
y - lhs.
y * rhs.
x;
1929template <
typename T>
1935 lhs.
z * rhs.
x - lhs.
x * rhs.
z,
1936 lhs.
x * rhs.
y - lhs.
y * rhs.
x);
1944template <
typename T>
1950#ifdef mi_base_assert_enabled
1951 constexpr T eps = 1e-6f;
1960 if(
abs(n.x) <
abs(n.y)) {
1992template <
typename T>
2000#ifdef mi_base_assert_enabled
2001 constexpr T eps = 1e-6f;
2023 if(
dot( *b,v) < T(0))
2043template <
typename T2, Size DIM2,
typename T1, Size DIM1>
2046 const T2& fill = T2(0))
2050 for(
Size i = 0; i < dim_min; ++i)
2051 result[i] = T2(v[i]);
2052 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:58
#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
float Float32
32-bit float.
Definition: types.h:51
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:112
Sint64 Difference
Signed integral type that is large enough to hold the difference of two pointers.
Definition: types.h:122
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:1114
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:1130
Sint32 dot(Sint32 a, Sint32 b)
Returns the inner product (a.k.a. dot or scalar product) of two integers.
Definition: function.h:1021
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:1162
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:1101
Float32 length(Float32 a)
Returns the Euclidean norm of the scalar a (its absolute value).
Definition: function.h:1047
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:1146
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:1090
#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:468
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:562
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:533
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:576
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:516
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:548
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:484
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:500
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:670
Color frac(const Color &c)
Returns a color with the elementwise positive fractional part of the color c.
Definition: color.h:613
Color sqrt(const Color &c)
Returns the square root of each element of c.
Definition: color.h:792
Color acos(const Color &c)
Returns a color with the elementwise arc cosine of the color c.
Definition: color.h:465
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:504
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:510
Color abs(const Color &c)
Returns a color with the elementwise absolute values of the color c.
Definition: color.h:459
Color round(const Color &c)
Returns a color with the elements of color c rounded to nearest integers.
Definition: color.h:725
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:701
Color atan(const Color &c)
Returns a color with the elementwise arc tangent of the color c.
Definition: color.h:489
bool isfinite(const Color &c)
Indicates whether all components of the color are finite.
Definition: color.h:810
Color step(const Color &a, const Color &c)
Returns elementwise 0 if c is less than a and 1 otherwise.
Definition: color.h:798
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:569
Color tan(const Color &c)
Returns a color with the elementwise tangent of the color c.
Definition: color.h:804
Color atan2(const Color &c, const Color &d)
Returns a color with the elementwise arc tangent of the color c / d.
Definition: color.h:497
Color sin(const Color &c)
Returns a color with the elementwise sine of the color c.
Definition: color.h:749
Color degrees(const Color &c)
Converts elementwise radians in c to degrees.
Definition: color.h:552
Color saturate(const Color &c)
Returns the color c clamped elementwise to the range [0,1].
Definition: color.h:737
Color rsqrt(const Color &c)
Returns the reciprocal of the square root of each element of c.
Definition: color.h:731
bool any(const Color &c)
Returns true if any element of c is not equal to zero.
Definition: color.h:477
Color radians(const Color &c)
Converts elementwise degrees in c to radians.
Definition: color.h:719
Color exp2(const Color &c)
Returns a color with elementwise 2 to the power of the element in the color c.
Definition: color.h:584
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:559
Color log(const Color &c)
Returns a color with elementwise natural logarithm of the color c.
Definition: color.h:677
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:591
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:770
Color sign(const Color &c)
Returns the elementwise sign of color c.
Definition: color.h:743
Color fmod(const Color &a, const Color &b)
Returns elementwise a modulo b, in other words, the remainder of a/b.
Definition: color.h:599
Color cos(const Color &c)
Returns a color with the elementwise cosine of the color c.
Definition: color.h:546
Color pow(const Color &a, const Color &b)
Returns the color a elementwise to the power of b.
Definition: color.h:707
bool all(const Color &c)
Returns true if all elements of c are not equal to zero.
Definition: color.h:471
Color log10(const Color &c)
Returns a color with elementwise base 10 logarithm of the color c.
Definition: color.h:692
Color log2(const Color &c)
Returns a color with elementwise base 2 logarithm of the color c.
Definition: color.h:683
Color exp(const Color &c)
Returns a color with elementwise e to the power of the element in the color c.
Definition: color.h:578
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:638
void sincos(const Color &a, Color &s, Color &c)
Computes elementwise the sine s and cosine c of angles a simultaneously.
Definition: color.h:757
Color asin(const Color &c)
Returns a color with the elementwise arc sine of the color c.
Definition: color.h:483
void transform(const Vector &vec, ResultVector &result, UnaryFunctor f)
Generic transform function that applies a unary functor (return value).
Definition: function.h:236
void for_each(Vector &vec, UnaryFunctor f)
Generic transform function that applies a unary functor (in-place).
Definition: function.h:304
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:289
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:271
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:425
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:1314
void set(Size i, T value)
Sets the i-th vector element to value.
Definition: vector.h:648
Vector(T2 const (&array)[DIM])
Constructor initializes the vector elements from an array of dimension DIM.
Definition: vector.h:416
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:1921
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:555
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<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:1404
Vector(const Color_struct &color)
Dedicated constructor, for dimension 4 only, that initializes the vector elements from a color interp...
Definition: vector.h:579
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:1415
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:543
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:398
const T & const_reference
Const reference to element.
Definition: vector.h:297
bool operator<=(Vector<T, DIM> rhs) const
Returns true if lhs is lexicographically less than or equal to rhs.
Definition: vector.h:697
T & reference
Mutable reference to element.
Definition: vector.h:296
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:567
bool operator>=(Vector<T, DIM> rhs) const
Returns true if lhs is lexicographically greater than or equal to rhs.
Definition: vector.h:713
bool operator>(Vector<T, DIM> rhs) const
Returns true if lhs is lexicographically greater than rhs.
Definition: vector.h:705
T * pointer
Mutable pointer to element.
Definition: vector.h:294
Vector(const Vector_struct<T, DIM> &vec)
Constructor from underlying storage type.
Definition: vector.h:343
Vector<T, DIM> & operator++(Vector<T, DIM> &vec)
Pre-increments all elements of vec and returns the result. Modifies vec.
Definition: vector.h:1229
Vector<T, DIM> & operator--(Vector<T, DIM> &vec)
Pre-decrements all elements of vec and returns the result. Modifies vec.
Definition: vector.h:1237
static constexpr Size max_size()
Constant maximum size of the vector.
Definition: vector.h:306
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:483
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:1371
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:495
static constexpr Size SIZE
Constant size of the vector.
Definition: vector.h:300
static constexpr Size size()
Constant size of the vector.
Definition: vector.h:303
T & operator[](Size i)
Accesses the i-th vector element.
Definition: vector.h:621
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:434
Size size_type
Size type, unsigned.
Definition: vector.h:292
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:2044
const T & get(Size i) const
Returns the i-th vector element.
Definition: vector.h:639
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:872
Difference difference_type
Difference type, signed.
Definition: vector.h:293
void make_basis(const Vector<T, 3> &n, Vector<T, 3> *const u, Vector<T, 3> *const v)
Computes a basis of 3D space with one given vector.
Definition: vector.h:1945
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.
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:507
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:675
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:531
T z
z-coordinate.
Definition: vector.h:165
const T * const_pointer
Const pointer to element.
Definition: vector.h:295
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:1393
T z
z-coordinate.
Definition: vector.h:157
T value_type
Element type.
Definition: vector.h:291
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:459
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:925
Float32 r
Red color component.
Definition: vector.h:69
bool normalize()
Normalizes this vector to unit length.
Definition: vector.h:662
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:1248
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:1347
bool operator<(Vector<T, DIM> rhs) const
Returns true if lhs is lexicographically less than rhs.
Definition: vector.h:689
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:1281
static constexpr Size DIMENSION
Constant dimension of the vector.
Definition: vector.h:299
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:447
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:1360
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:471
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:1382
bool operator!=(Vector<T, DIM> rhs) const
Returns true if lhs is elementwise not equal to rhs.
Definition: vector.h:681
T x
x-coordinate.
Definition: vector.h:142
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:519
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: example_derivatives.dox:5
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:151
Functor for the equality comparison operator, ==.
Definition: function.h:78
Functor for the greater-than-or-equal comparison operator, >=.
Definition: function.h:113
Functor for the greater-than comparison operator, >.
Definition: function.h:106
Functor for the less-than-or-equal comparison operator, <=.
Definition: function.h:99
Functor for the less-than comparison operator, <.
Definition: function.h:92
Functor for the inequality comparison operator, !=.
Definition: function.h:85
Functor for the logical not operator, !.
Definition: function.h:172
Functor for the logical or operator, ||.
Definition: function.h:158
Functor for the pre-decrement operator, --.
Definition: function.h:193
Functor for the pre-increment operator, ++.
Definition: function.h:179
Functor for the xor operator, ^.
Definition: function.h:165