11 #ifndef MI_MATH_VECTOR_H
12 #define MI_MATH_VECTOR_H
134 template <
typename T, Size DIM>
174 template <
typename T, Size DIM>
181 template <
typename T, Size DIM>
188 template <
typename T>
195 template <
typename T>
202 template <
typename T>
209 template <
typename T>
216 template <
typename T>
223 template <
typename T>
230 template <
typename T>
237 template <
typename T>
249 template <
class T, Size DIM>
253 template <
typename T, Size DIM>
260 Vector_proxy_& operator=(
const Vector_proxy_& o);
301 template <
class T, Size DIM>
302 class Vector :
public Vector_struct<T, DIM>
339 inline const T*
end()
const {
return begin() + DIM; }
344 #if defined(DEBUG) || (defined(_MSC_VER) && _MSC_VER <= 1310)
352 T v = (Traits::has_signaling_NaN) ? Traits::signaling_NaN()
354 for(
Size i(0u); i < DIM; ++i)
362 for(
Size i(0u); i < DIM; ++i)
369 for(
Size i(0u); i < DIM; ++i)
386 template <
typename Iterator>
389 for(
Size i(0u); i < DIM; ++i, ++p)
404 template <
typename T2>
405 inline explicit Vector( T2
const (& array)[DIM])
407 for(
Size i(0u); i < DIM; ++i)
408 (*
this)[i] = array[i];
413 template <
typename T2>
416 for(
Size i(0u); i < DIM; ++i)
417 (*
this)[i] = T(other[i]);
575 for(
Size i(0u); i < DIM; ++i)
576 (*
this)[i] = other[i];
583 for(
Size i(0u); i < DIM; ++i)
622 inline const T&
get(
Size i)
const
647 const T rec_length = T(1) /
length( *
this);
648 const bool result =
isfinite( rec_length);
650 (*this) *= rec_length;
674 inline bool operator<( Vector_proxy_<T,DIM> rhs)
const
682 inline bool operator<=( Vector_proxy_<T,DIM> rhs)
const
708 template <
typename T, Size DIM>
713 for(
Size i(0u); i < DIM; ++i)
719 template <
typename T, Size DIM>
724 for(
Size i(0u); i < DIM; ++i)
730 template <
typename T, Size DIM>
735 for(
Size i(0u); i < DIM; ++i)
742 template <
typename T, Size DIM>
747 for(
Size i(0u); i < DIM; ++i)
753 template <
typename T,
typename U, Size DIM>
758 for(
Size i(0u); i < DIM; ++i)
759 lhs[i] = T(lhs[i] / rhs[i]);
764 template <
typename T, Size DIM>
774 template <
typename T, Size DIM>
784 template <
typename T, Size DIM>
795 template <
typename T, Size DIM>
805 template <
typename T,
typename U, Size DIM>
815 template <
typename T, Size DIM>
819 for(
Size i(0u); i < DIM; ++i)
829 template <
typename T,
typename TT, Size DIM>
834 for(
Size i(0u); i < DIM; ++i)
842 template <
typename T,
typename TT, Size DIM>
847 for(
Size i(0u); i < DIM; ++i)
853 template <
typename T,
typename TT, Size DIM>
858 for(
Size i(0u); i < DIM; ++i)
864 template <
typename T,
typename TT, Size DIM>
874 template <
typename T,
typename TT, Size DIM>
886 template <
typename T,
typename TT, Size DIM>
896 template <
typename T,
typename TT, Size DIM>
909 template <
typename T, Size DIM>
917 template <
typename T, Size DIM>
1040 template <
typename T, Size DIM>
1051 template <
typename T, Size DIM>
1062 template <
typename T, Size DIM>
1073 template <
typename T, Size DIM>
1084 template <
typename T, Size DIM>
1095 template <
typename T, Size DIM>
1109 template <
typename T, Size DIM>
1113 for(
Size i = 0; i != DIM; ++i)
1114 result[i] =
abs( v[i]);
1119 template <
typename T, Size DIM>
1123 for(
Size i = 0; i != DIM; ++i)
1124 result[i] =
acos( v[i]);
1129 template <
typename T, Size DIM>
1132 for(
Size i = 0; i != DIM; ++i)
1139 template <
typename T, Size DIM>
1142 for(
Size i = 0; i != DIM; ++i)
1149 template <
typename T, Size DIM>
1153 for(
Size i = 0; i != DIM; ++i)
1154 result[i] =
asin( v[i]);
1159 template <
typename T, Size DIM>
1163 for(
Size i = 0; i != DIM; ++i)
1164 result[i] =
atan( v[i]);
1171 template <
typename T, Size DIM>
1175 for(
Size i = 0; i != DIM; ++i)
1176 result[i] =
atan2( v[i], w[i]);
1182 template <
typename T, Size DIM>
1186 for(
Size i = 0; i != DIM; ++i)
1187 result[i] =
ceil( v[i]);
1192 template <
typename T, Size DIM>
1199 for(
Size i = 0u; i < DIM; ++i)
1200 result[i] =
clamp( v[i], low[i], high[i]);
1205 template <
typename T, Size DIM>
1212 for(
Size i = 0u; i < DIM; ++i)
1213 result[i] =
clamp( v[i], low[i], high);
1218 template <
typename T, Size DIM>
1225 for(
Size i = 0u; i < DIM; ++i)
1226 result[i] =
clamp( v[i], low, high[i]);
1231 template <
typename T, Size DIM>
1238 for(
Size i = 0u; i < DIM; ++i)
1239 result[i] =
clamp( v[i], low, high);
1244 template <
typename T, Size DIM>
1248 for(
Size i = 0; i != DIM; ++i)
1249 result[i] =
cos( v[i]);
1254 template <
typename T, Size DIM>
1258 for(
Size i = 0; i != DIM; ++i)
1264 template <
typename T, Size DIM>
1270 for(
Size i(0u); i < Vector<T,DIM>::DIMENSION; ++i)
1276 template <
typename T, Size DIM>
1282 for(
Size i(0u); i < Vector<T,DIM>::DIMENSION; ++i)
1288 template <
typename T, Size DIM>
1292 for(
Size i = 0; i != DIM; ++i)
1293 result[i] =
exp( v[i]);
1298 template <
typename T, Size DIM>
1302 for(
Size i = 0; i != DIM; ++i)
1303 result[i] =
exp2( v[i]);
1309 template <
typename T, Size DIM>
1313 for(
Size i = 0; i != DIM; ++i)
1314 result[i] =
floor( v[i]);
1321 template <
typename T, Size DIM>
1325 for(
Size i = 0; i != DIM; ++i)
1326 result[i] =
fmod( a[i], b[i]);
1333 template <
typename T, Size DIM>
1337 for(
Size i = 0; i != DIM; ++i)
1338 result[i] =
fmod( a[i], b);
1343 template <
typename T, Size DIM>
1347 for(
Size i = 0; i != DIM; ++i)
1348 result[i] =
frac( v[i]);
1353 template <
typename T, Size DIM>
1359 for(
Size i = 0u; i < DIM; ++i)
1367 template <
typename T, Size DIM>
1374 for(
Size i = 0; i != DIM; ++i)
1375 result[i] = v1[i] * (T(1)-t[i]) + v2[i] * t[i];
1381 template <
typename T, Size DIM>
1390 for(
Size i = 0; i != DIM; ++i)
1391 result[i] = v1[i] * t2 + v2[i] * t;
1396 template <
typename T, Size DIM>
1400 for(
Size i = 0; i != DIM; ++i)
1401 result[i] =
log( v[i]);
1406 template <
typename T, Size DIM>
1410 for(
Size i = 0; i != DIM; ++i)
1416 template <
typename T, Size DIM>
1420 for(
Size i = 0; i != DIM; ++i)
1421 result[i] =
log10( v[i]);
1429 template <
typename T, Size DIM>
1433 for(
Size j = 0; j != DIM; ++j)
1434 result[j] =
modf( v[j], i[j]);
1439 template <
typename T, Size DIM>
1443 for(
Size i = 0; i != DIM; ++i)
1444 result[i] =
pow( a[i], b[i]);
1449 template <
typename T, Size DIM>
1453 for(
Size i = 0; i != DIM; ++i)
1454 result[i] =
pow( a[i], b);
1459 template <
typename T, Size DIM>
1463 for(
Size i = 0; i != DIM; ++i)
1469 template <
typename T, Size DIM>
1473 for(
Size i = 0; i != DIM; ++i)
1474 result[i] =
round( v[i]);
1479 template <
typename T, Size DIM>
1483 for(
Size i = 0; i != DIM; ++i)
1484 result[i] =
rsqrt( v[i]);
1489 template <
typename T, Size DIM>
1493 for(
Size i = 0; i != DIM; ++i)
1499 template <
typename T, Size DIM>
1503 for(
Size i = 0; i != DIM; ++i)
1504 result[i] =
sign( v[i]);
1509 template <
typename T, Size DIM>
1513 for(
Size i = 0; i != DIM; ++i)
1514 result[i] =
sin( v[i]);
1521 template <
typename T, Size DIM>
1524 for(
Size i = 0; i != DIM; ++i)
1525 sincos( a[i], s[i], c[i]);
1533 template <
typename T, Size DIM>
1540 for(
Size i = 0; i != DIM; ++i)
1550 template <
typename T, Size DIM>
1557 for(
Size i = 0; i != DIM; ++i)
1563 template <
typename T, Size DIM>
1567 for(
Size i = 0; i != DIM; ++i)
1568 result[i] =
sqrt( v[i]);
1573 template <
typename T, Size DIM>
1577 for(
Size i = 0; i != DIM; ++i)
1578 result[i] =
step( a[i], v[i]);
1583 template <
typename T, Size DIM>
1587 for(
Size i = 0; i != DIM; ++i)
1588 result[i] =
tan( v[i]);
1596 template <
typename T>
1601 return lhs.x * rhs.y - lhs.y * rhs.x;
1605 template <
typename T>
1610 return Vector<T,3>( lhs.y * rhs.z - lhs.z * rhs.y,
1611 lhs.z * rhs.x - lhs.x * rhs.z,
1612 lhs.x * rhs.y - lhs.y * rhs.x);
1620 template <
typename T>
1626 #ifdef mi_base_assert_enabled
1627 const T eps = 1e-6f;
1636 if(
abs(n.x) <
abs(n.y)) {
1668 template <
typename T>
1676 const T eps = 1e-6f;
1698 if(
dot( *b,v) < T(0))
1718 template <
typename T2, Size DIM2,
typename T1, Size DIM1>
1721 const T2& fill = T2(0))
1725 for(
Size i = 0; i < dim_min; ++i)
1726 result[i] = T2(v[i]);
1727 for(
Size i = dim_min; i < DIM2; ++i)
1738 #endif // MI_MATH_VECTOR_H