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)
339#if (__cplusplus >= 201103L)
347 for(
Size i(0u); i < DIM; ++i)
354 for(
Size i(0u); i < DIM; ++i)
371 template <
typename Iterator>
374 for(
Size i(0u); i < DIM; ++i, ++p)
389 template <
typename T2>
390 inline explicit Vector( T2
const (& array)[DIM])
392 for(
Size i(0u); i < DIM; ++i)
393 (*
this)[i] = array[i];
398 template <
typename T2>
401 for(
Size i(0u); i < DIM; ++i)
402 (*
this)[i] = T(other[i]);
407 template <
typename T2>
410 for(
Size i(0u); i < DIM; ++i)
567#if (__cplusplus >= 201103L)
572 for(
Size i(0u); i < DIM; ++i)
573 (*
this)[i] = other[i];
581 for(
Size i(0u); i < DIM; ++i)
645 const T rec_length = T(1) /
length( *
this);
646 const bool result =
isfinite( rec_length);
648 (*this) *= rec_length;
704template <
typename T, Size DIM>
709 for(
Size i(0u); i < DIM; ++i)
715template <
typename T, Size DIM>
720 for(
Size i(0u); i < DIM; ++i)
726template <
typename T, Size DIM>
731 for(
Size i(0u); i < DIM; ++i)
738template <
typename T, Size DIM>
743 for(
Size i(0u); i < DIM; ++i)
749template <
typename T,
typename U, Size DIM>
754 for(
Size i(0u); i < DIM; ++i)
760template <
typename T, Size DIM>
770template <
typename T, Size DIM>
780template <
typename T, Size DIM>
791template <
typename T, Size DIM>
801template <
typename T,
typename U, Size DIM>
811template <
typename T, Size DIM>
815 for(
Size i(0u); i < DIM; ++i)
826template <
typename T, Size DIM>
835template <
typename T, Size DIM>
844template <
typename T, Size DIM>
854template <
typename T, Size DIM>
863template <
typename T,
typename U, Size DIM>
872template <
typename T, Size DIM>
881template <
typename T, Size DIM>
890template <
typename T, Size DIM>
900template <
typename T, Size DIM>
909template <
typename T,
typename U, Size DIM>
918template <
typename T, Size DIM>
929template <
typename T,
typename TT, Size DIM>
934 for(
Size i(0u); i < DIM; ++i)
942template <
typename T,
typename TT, Size DIM>
947 for(
Size i(0u); i < DIM; ++i)
953template <
typename T,
typename TT, Size DIM>
958 for(
Size i(0u); i < DIM; ++i)
964template <
typename T,
typename TT, Size DIM>
974template <
typename T,
typename TT, Size DIM>
986template <
typename T,
typename TT, Size DIM>
996template <
typename T,
typename TT, Size DIM>
1009template <
typename T, Size DIM>
1017template <
typename T, Size DIM>
1140template <
typename T, Size DIM>
1151template <
typename T, Size DIM>
1162template <
typename T, Size DIM>
1173template <
typename T, Size DIM>
1184template <
typename T, Size DIM>
1195template <
typename T, Size DIM>
1209template <
typename T, Size DIM>
1213 for(
Size i = 0; i != DIM; ++i)
1219template <
typename T, Size DIM>
1223 for(
Size i = 0; i != DIM; ++i)
1229template <
typename T, Size DIM>
1232 for(
Size i = 0; i != DIM; ++i)
1239template <
typename T, Size DIM>
1242 for(
Size i = 0; i != DIM; ++i)
1249template <
typename T, Size DIM>
1253 for(
Size i = 0; i != DIM; ++i)
1259template <
typename T, Size DIM>
1263 for(
Size i = 0; i != DIM; ++i)
1271template <
typename T, Size DIM>
1275 for(
Size i = 0; i != DIM; ++i)
1282template <
typename T, Size DIM>
1286 for(
Size i = 0; i != DIM; ++i)
1292template <
typename T, Size DIM>
1299 for(
Size i = 0u; i < DIM; ++i)
1306template <
typename T, Size DIM>
1313 for(
Size i = 0u; i < DIM; ++i)
1319template <
typename T, Size DIM>
1326 for(
Size i = 0u; i < DIM; ++i)
1332template <
typename T, Size DIM>
1339 for(
Size i = 0u; i < DIM; ++i)
1345template <
typename T, Size DIM>
1349 for(
Size i = 0; i != DIM; ++i)
1355template <
typename T, Size DIM>
1359 for(
Size i = 0; i != DIM; ++i)
1365template <
typename T, Size DIM>
1371 for(
Size i(0u); i < Vector<T,DIM>::DIMENSION; ++i)
1378template <
typename T, Size DIM>
1384 for(
Size i(0u); i < Vector<T,DIM>::DIMENSION; ++i)
1391template <
typename T, Size DIM>
1395 for(
Size i = 0; i != DIM; ++i)
1401template <
typename T, Size DIM>
1405 for(
Size i = 0; i != DIM; ++i)
1412template <
typename T, Size DIM>
1416 for(
Size i = 0; i != DIM; ++i)
1424template <
typename T, Size DIM>
1428 for(
Size i = 0; i != DIM; ++i)
1436template <
typename T, Size DIM>
1440 for(
Size i = 0; i != DIM; ++i)
1446template <
typename T, Size DIM>
1450 for(
Size i = 0; i != DIM; ++i)
1456template <
typename T, Size DIM>
1462 for(
Size i = 0u; i < DIM; ++i)
1470template <
typename T, Size DIM>
1477 for(
Size i = 0; i != DIM; ++i)
1485template <
typename T, Size DIM>
1494 for(
Size i = 0; i != DIM; ++i)
1500template <
typename T, Size DIM>
1504 for(
Size i = 0; i != DIM; ++i)
1510template <
typename T, Size DIM>
1514 for(
Size i = 0; i != DIM; ++i)
1520template <
typename T, Size DIM>
1524 for(
Size i = 0; i != DIM; ++i)
1533template <
typename T, Size DIM>
1537 for(
Size j = 0; j != DIM; ++j)
1543template <
typename T, Size DIM>
1547 for(
Size i = 0; i != DIM; ++i)
1553template <
typename T, Size DIM>
1557 for(
Size i = 0; i != DIM; ++i)
1563template <
typename T, Size DIM>
1567 for(
Size i = 0; i != DIM; ++i)
1573template <
typename T, Size DIM>
1577 for(
Size i = 0; i != DIM; ++i)
1583template <
typename T, Size DIM>
1587 for(
Size i = 0; i != DIM; ++i)
1593template <
typename T, Size DIM>
1597 for(
Size i = 0; i != DIM; ++i)
1603template <
typename T, Size DIM>
1607 for(
Size i = 0; i != DIM; ++i)
1613template <
typename T, Size DIM>
1617 for(
Size i = 0; i != DIM; ++i)
1625template <
typename T, Size DIM>
1628 for(
Size i = 0; i != DIM; ++i)
1637template <
typename T, Size DIM>
1644 for(
Size i = 0; i != DIM; ++i)
1655template <
typename T, Size DIM>
1662 for(
Size i = 0; i != DIM; ++i)
1668template <
typename T, Size DIM>
1672 for(
Size i = 0; i != DIM; ++i)
1678template <
typename T, Size DIM>
1682 for(
Size i = 0; i != DIM; ++i)
1688template <
typename T, Size DIM>
1692 for(
Size i = 0; i != DIM; ++i)
1701template <
typename T>
1706 return lhs.
x * rhs.
y - lhs.
y * rhs.
x;
1710template <
typename T>
1716 lhs.
z * rhs.
x - lhs.
x * rhs.
z,
1717 lhs.
x * rhs.
y - lhs.
y * rhs.
x);
1725template <
typename T>
1731#ifdef mi_base_assert_enabled
1732 const T eps = 1e-6f;
1741 if(
abs(n.x) <
abs(n.y)) {
1773template <
typename T>
1781 const T eps = 1e-6f;
1803 if(
dot( *b,v) < T(0))
1823template <
typename T2, Size DIM2,
typename T1, Size DIM1>
1826 const T2& fill = T2(0))
1830 for(
Size i = 0; i < dim_min; ++i)
1831 result[i] = T2(v[i]);
1832 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
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:1174
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:1190
Sint32 dot(Sint32 a, Sint32 b)
Returns the inner product (a.k.a. dot or scalar product) of two integers.
Definition: function.h:1081
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:1222
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:1161
Float32 length(Float32 a)
Returns the Euclidean norm of the scalar a (its absolute value).
Definition: function.h:1107
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:1206
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:1150
#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:625
Color sqrt(const Color &c)
Returns the square root of each element of c.
Definition: color.h:804
Color acos(const Color &c)
Returns a color with the elementwise arc cosine of the color c.
Definition: color.h:477
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:516
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:522
Color abs(const Color &c)
Returns a color with the elementwise absolute values of the color c.
Definition: color.h:471
Color round(const Color &c)
Returns a color with the elements of color c rounded to nearest integers.
Definition: color.h:737
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:713
Color atan(const Color &c)
Returns a color with the elementwise arc tangent of the color c.
Definition: color.h:501
bool isfinite(const Color &c)
Indicates whether all components of the color are finite.
Definition: color.h:822
Color step(const Color &a, const Color &c)
Returns elementwise 0 if c is less than a and 1 otherwise.
Definition: color.h:810
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:581
Color tan(const Color &c)
Returns a color with the elementwise tangent of the color c.
Definition: color.h:816
Color atan2(const Color &c, const Color &d)
Returns a color with the elementwise arc tangent of the color c / d.
Definition: color.h:509
Color sin(const Color &c)
Returns a color with the elementwise sine of the color c.
Definition: color.h:761
Color degrees(const Color &c)
Converts elementwise radians in c to degrees.
Definition: color.h:564
Color saturate(const Color &c)
Returns the color c clamped elementwise to the range [0,1].
Definition: color.h:749
Color rsqrt(const Color &c)
Returns the reciprocal of the square root of each element of c.
Definition: color.h:743
bool any(const Color &c)
Returns true if any element of c is not equal to zero.
Definition: color.h:489
Color radians(const Color &c)
Converts elementwise degrees in c to radians.
Definition: color.h:731
Color exp2(const Color &c)
Returns a color with elementwise 2 to the power of the element in the color c.
Definition: color.h:596
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:571
Color log(const Color &c)
Returns a color with elementwise natural logarithm of the color c.
Definition: color.h:689
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:603
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:782
Color sign(const Color &c)
Returns the elementwise sign of color c.
Definition: color.h:755
Color fmod(const Color &a, const Color &b)
Returns elementwise a modulo b, in other words, the remainder of a/b.
Definition: color.h:611
Color cos(const Color &c)
Returns a color with the elementwise cosine of the color c.
Definition: color.h:558
Color pow(const Color &a, const Color &b)
Returns the color a elementwise to the power of b.
Definition: color.h:719
bool all(const Color &c)
Returns true if all elements of c are not equal to zero.
Definition: color.h:483
Color log10(const Color &c)
Returns a color with elementwise base 10 logarithm of the color c.
Definition: color.h:704
Color log2(const Color &c)
Returns a color with elementwise base 2 logarithm of the color c.
Definition: color.h:695
Color exp(const Color &c)
Returns a color with elementwise e to the power of the element in the color c.
Definition: color.h:590
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:650
void sincos(const Color &a, Color &s, Color &c)
Computes elementwise the sine s and cosine c of angles a simultaneously.
Definition: color.h:769
Color asin(const Color &c)
Returns a color with the elementwise arc sine of the color c.
Definition: color.h:495
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:399
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:1095
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:629
Vector(T2 const (&array)[DIM])
Constructor initializes the vector elements from an array of dimension DIM.
Definition: vector.h:390
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:1702
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:531
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:1185
Vector(const Color_struct &color)
Dedicated constructor, for dimension 4 only, that initializes the vector elements from a color interp...
Definition: vector.h:557
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:1196
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:518
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:372
bool operator<=(Vector<T, DIM> rhs) const
Returns true if lhs is lexicographically less than or equal to rhs.
Definition: vector.h:678
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:544
bool operator>=(Vector<T, DIM> rhs) const
Returns true if lhs is lexicographically greater than or equal to rhs.
Definition: vector.h:694
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:686
Vector(const Vector_struct<T, DIM> &vec)
Constructor from underlying storage type.
Definition: vector.h:345
Vector<T, DIM> & operator++(Vector<T, DIM> &vec)
Pre-increments all elements of vec and returns the result. Modifies vec.
Definition: vector.h:1010
Vector<T, DIM> & operator--(Vector<T, DIM> &vec)
Pre-decrements all elements of vec and returns the result. Modifies vec.
Definition: vector.h:1018
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:453
Vector(T v)
Constructor initializes all vector elements to the value v.
Definition: vector.h:352
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:1152
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:465
T & operator[](Size i)
Accesses the i-th vector element.
Definition: vector.h:602
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:408
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:1824
const T & get(Size i) const
Returns the i-th vector element.
Definition: vector.h:620
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:739
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:478
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:656
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:505
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:1174
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:429
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:792
Float32 r
Red color component.
Definition: vector.h:69
bool normalize()
Normalizes this vector to unit length.
Definition: vector.h:643
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:1029
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:1128
bool operator<(Vector<T, DIM> rhs) const
Returns true if lhs is lexicographically less than rhs.
Definition: vector.h:670
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:1062
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:418
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:1141
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:441
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:1726
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:1163
bool operator!=(Vector<T, DIM> rhs) const
Returns true if lhs is elementwise not equal to rhs.
Definition: vector.h:662
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:492
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