10 #ifndef INCLUDED_ATOMSMATHMATRIX_H
11 #define INCLUDED_ATOMSMATHMATRIX_H
13 #include <AtomsMath/ImathFun.h>
14 #include <AtomsMath/ImathNamespace.h>
15 #include <AtomsMath/ImathPlatform.h>
16 #include <AtomsMath/ImathShear.h>
17 #include <AtomsMath/ImathVec.h>
25 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
27 # pragma warning(disable : 4290)
30 ATOMSMATH_INTERNAL_NAMESPACE_HEADER_ENTER
56 ATOMSMATH_HOSTDEVICE T*
operator[] (
int i) noexcept;
59 ATOMSMATH_HOSTDEVICE
const T*
operator[] (
int i)
const noexcept;
71 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix22() noexcept;
77 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix22 (T a) noexcept;
83 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix22 (const T a[2][2]) noexcept;
89 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix22 (T a, T b, T c, T d) noexcept;
92 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix22 (const
Matrix22& v) noexcept;
95 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 explicit
Matrix22 (const
Matrix22<S>& v) noexcept;
98 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22& operator= (const
Matrix22& v) noexcept;
101 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22& operator= (T a) noexcept;
112 ATOMSMATH_HOSTDEVICE T*
getValue() noexcept;
115 ATOMSMATH_HOSTDEVICE const T*
getValue() const noexcept;
133 ATOMSMATH_HOSTDEVICE constexpr
bool operator== (const
Matrix22& v) const noexcept;
136 ATOMSMATH_HOSTDEVICE constexpr
bool operator!= (const
Matrix22& v) const noexcept;
153 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22& operator+= (const
Matrix22& v) noexcept;
156 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22& operator+= (T a) noexcept;
159 ATOMSMATH_HOSTDEVICE constexpr
Matrix22 operator+ (const
Matrix22& v) const noexcept;
162 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22& operator-= (const
Matrix22& v) noexcept;
165 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22& operator-= (T a) noexcept;
168 ATOMSMATH_HOSTDEVICE constexpr
Matrix22 operator- (const
Matrix22& v) const noexcept;
171 ATOMSMATH_HOSTDEVICE constexpr
Matrix22 operator-() const noexcept;
174 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22&
negate() noexcept;
177 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22& operator*= (T a) noexcept;
180 ATOMSMATH_HOSTDEVICE constexpr
Matrix22 operator* (T a) const noexcept;
183 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22& operator/= (T a) noexcept;
186 ATOMSMATH_HOSTDEVICE constexpr
Matrix22 operator/ (T a) const noexcept;
189 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22& operator*= (const
Matrix22& v) noexcept;
192 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix22 operator* (const
Matrix22& v) const noexcept;
220 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22&
invert() noexcept;
227 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix22<T>
inverse() const noexcept;
230 ATOMSMATH_HOSTDEVICE constexpr T
determinant() const noexcept;
238 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22&
rotate (S r) noexcept;
242 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22&
setScale (T s) noexcept;
251 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix22&
scale (const
Vec2<S>& s) noexcept;
259 ATOMSMATH_HOSTDEVICE constexpr static T
baseTypeLowest() noexcept {
return std::numeric_limits<T>::lowest(); }
262 ATOMSMATH_HOSTDEVICE constexpr
static T
baseTypeMax() noexcept {
return std::numeric_limits<T>::max(); }
265 ATOMSMATH_HOSTDEVICE constexpr
static T
baseTypeSmallest() noexcept {
return std::numeric_limits<T>::min(); }
268 ATOMSMATH_HOSTDEVICE constexpr
static T
baseTypeEpsilon() noexcept {
return std::numeric_limits<T>::epsilon(); }
273 ATOMSMATH_HOSTDEVICE constexpr
static unsigned int dimensions() noexcept {
return 2; }
283 template <
typename R,
typename S>
struct isSameType
291 template <
typename R>
struct isSameType<R, R>
317 ATOMSMATH_HOSTDEVICE T*
operator[] (
int i) noexcept;
320 ATOMSMATH_HOSTDEVICE
const T*
operator[] (
int i)
const noexcept;
332 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix33() noexcept;
338 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix33 (T a) noexcept;
344 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix33 (const T a[3][3]) noexcept;
350 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix33 (T a, T b, T c, T d, T e, T f, T g, T h, T i) noexcept;
353 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix33 (const
Matrix33& v) noexcept;
356 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 explicit
Matrix33 (const
Matrix33<S>& v) noexcept;
359 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33& operator= (const
Matrix33& v) noexcept;
362 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33& operator= (T a) noexcept;
373 ATOMSMATH_HOSTDEVICE T*
getValue() noexcept;
376 ATOMSMATH_HOSTDEVICE const T*
getValue() const noexcept;
394 ATOMSMATH_HOSTDEVICE constexpr
bool operator== (const
Matrix33& v) const noexcept;
397 ATOMSMATH_HOSTDEVICE constexpr
bool operator!= (const
Matrix33& v) const noexcept;
414 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33& operator+= (const
Matrix33& v) noexcept;
417 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33& operator+= (T a) noexcept;
420 ATOMSMATH_HOSTDEVICE constexpr
Matrix33 operator+ (const
Matrix33& v) const noexcept;
423 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33& operator-= (const
Matrix33& v) noexcept;
426 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33& operator-= (T a) noexcept;
429 ATOMSMATH_HOSTDEVICE constexpr
Matrix33 operator- (const
Matrix33& v) const noexcept;
432 ATOMSMATH_HOSTDEVICE constexpr
Matrix33 operator-() const noexcept;
435 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33&
negate() noexcept;
438 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33& operator*= (T a) noexcept;
441 ATOMSMATH_HOSTDEVICE constexpr
Matrix33 operator* (T a) const noexcept;
444 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33& operator/= (T a) noexcept;
447 ATOMSMATH_HOSTDEVICE constexpr
Matrix33 operator/ (T a) const noexcept;
450 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33& operator*= (const
Matrix33& v) noexcept;
453 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix33 operator* (const
Matrix33& v) const noexcept;
489 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33&
invert() noexcept;
496 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix33<T>
inverse() const noexcept;
518 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T
minorOf (const
int r, const
int c) const noexcept;
522 constexpr T
fastMinor (const
int r0, const
int r1, const
int c0, const
int c1) const noexcept;
525 ATOMSMATH_HOSTDEVICE constexpr T
determinant() const noexcept;
533 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33&
rotate (S r) noexcept;
537 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33&
setScale (T s) noexcept;
546 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33&
scale (const
Vec2<S>& s) noexcept;
563 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33&
setShear (const S& h) noexcept;
573 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33&
shear (const S& xy) noexcept;
578 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix33&
shear (const
Vec2<S>& h) noexcept;
586 ATOMSMATH_HOSTDEVICE constexpr static T
baseTypeLowest() noexcept {
return std::numeric_limits<T>::lowest(); }
589 ATOMSMATH_HOSTDEVICE constexpr
static T
baseTypeMax() noexcept {
return std::numeric_limits<T>::max(); }
592 ATOMSMATH_HOSTDEVICE constexpr
static T
baseTypeSmallest() noexcept {
return std::numeric_limits<T>::min(); }
595 ATOMSMATH_HOSTDEVICE constexpr
static T
baseTypeEpsilon() noexcept {
return std::numeric_limits<T>::epsilon(); }
600 ATOMSMATH_HOSTDEVICE constexpr
static unsigned int dimensions() noexcept {
return 3; }
609 template <
typename R,
typename S>
struct isSameType
617 template <
typename R>
struct isSameType<R, R>
643 ATOMSMATH_HOSTDEVICE T*
operator[] (
int i) noexcept;
646 ATOMSMATH_HOSTDEVICE
const T*
operator[] (
int i)
const noexcept;
659 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix44() noexcept;
666 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix44 (T a) noexcept;
673 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix44 (const T a[4][4]) noexcept;
680 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
681 Matrix44 (T a, T b, T c, T d, T e, T f, T g, T h, T i, T j, T k, T l, T m, T n, T o, T p) noexcept;
692 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix44 (const
Matrix44& v) noexcept;
695 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 explicit
Matrix44 (const
Matrix44<S>& v) noexcept;
698 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44& operator= (const
Matrix44& v) noexcept;
701 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44& operator= (T a) noexcept;
712 ATOMSMATH_HOSTDEVICE T*
getValue() noexcept;
715 ATOMSMATH_HOSTDEVICE const T*
getValue() const noexcept;
733 ATOMSMATH_HOSTDEVICE constexpr
bool operator== (const
Matrix44& v) const noexcept;
736 ATOMSMATH_HOSTDEVICE constexpr
bool operator!= (const
Matrix44& v) const noexcept;
753 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44& operator+= (const
Matrix44& v) noexcept;
756 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44& operator+= (T a) noexcept;
759 ATOMSMATH_HOSTDEVICE constexpr
Matrix44 operator+ (const
Matrix44& v) const noexcept;
762 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44& operator-= (const
Matrix44& v) noexcept;
765 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44& operator-= (T a) noexcept;
768 ATOMSMATH_HOSTDEVICE constexpr
Matrix44 operator- (const
Matrix44& v) const noexcept;
771 ATOMSMATH_HOSTDEVICE constexpr
Matrix44 operator-() const noexcept;
774 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44&
negate() noexcept;
777 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44& operator*= (T a) noexcept;
780 ATOMSMATH_HOSTDEVICE constexpr
Matrix44 operator* (T a) const noexcept;
783 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44& operator/= (T a) noexcept;
786 ATOMSMATH_HOSTDEVICE constexpr
Matrix44 operator/ (T a) const noexcept;
789 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44& operator*= (const
Matrix44& v) noexcept;
792 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix44 operator* (const
Matrix44& v) const noexcept;
834 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44&
invert() noexcept;
841 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14
Matrix44<T>
inverse() const noexcept;
852 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44&
gjInvert() noexcept;
863 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T
minorOf (const
int r, const
int c) const noexcept;
872 const
int c2) const noexcept;
875 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T
determinant() const noexcept;
892 ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44&
setScale (T s) noexcept;
901 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44&
scale (const
Vec3<S>& s) noexcept;
909 ATOMSMATH_HOSTDEVICE constexpr const
Vec3<T>
translation() const noexcept;
941 template <class S> ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const
Matrix44&
shear (const
Vec3<S>& h) noexcept;
961 ATOMSMATH_HOSTDEVICE constexpr static T
baseTypeLowest() noexcept {
return std::numeric_limits<T>::lowest(); }
964 ATOMSMATH_HOSTDEVICE constexpr
static T
baseTypeMax() noexcept {
return std::numeric_limits<T>::max(); }
967 ATOMSMATH_HOSTDEVICE constexpr
static T
baseTypeSmallest() noexcept {
return std::numeric_limits<T>::min(); }
970 ATOMSMATH_HOSTDEVICE constexpr
static T
baseTypeEpsilon() noexcept {
return std::numeric_limits<T>::epsilon(); }
975 ATOMSMATH_HOSTDEVICE constexpr
static unsigned int dimensions() noexcept {
return 4; }
984 template <
typename R,
typename S>
struct isSameType
992 template <
typename R>
struct isSameType<R, R>
1002 template <
class T> std::ostream& operator<< (std::ostream& s,
const Matrix22<T>& m);
1005 template <
class T> std::ostream& operator<< (std::ostream& s,
const Matrix33<T>& m);
1008 template <
class T> std::ostream& operator<< (std::ostream& s,
const Matrix44<T>& m);
1015 template <
class S,
class T>
1019 template <
class S,
class T>
1023 template <
class S,
class T>
1027 template <
class S,
class T>
1031 template <
class S,
class T>
1035 template <
class S,
class T>
1039 template <
class S,
class T>
1043 template <
class S,
class T>
1047 template <
class S,
class T>
1051 template <
class S,
class T>
1136 x[0][0] = v.x[0][0];
1137 x[0][1] = v.x[0][1];
1138 x[1][0] = v.x[1][0];
1139 x[1][1] = v.x[1][1];
1146 x[0][0] = T (v.x[0][0]);
1147 x[0][1] = T (v.x[0][1]);
1148 x[1][0] = T (v.x[1][0]);
1149 x[1][1] = T (v.x[1][1]);
1160 x[0][0] = v.
x[0][0];
1161 x[0][1] = v.x[0][1];
1162 x[1][0] = v.x[1][0];
1163 x[1][1] = v.x[1][1];
1182 return (T*) &x[0][0];
1189 return (
const T*) &x[0][0];
1197 v.x[0][0] = x[0][0];
1198 v.x[0][1] = x[0][1];
1199 v.x[1][0] = x[1][0];
1200 v.x[1][1] = x[1][1];
1208 x[0][0] = v.
x[0][0];
1209 x[0][1] = v.x[0][1];
1210 x[1][0] = v.x[1][0];
1211 x[1][1] = v.x[1][1];
1220 x[0][0] = v.
x[0][0];
1221 x[0][1] = v.x[0][1];
1222 x[1][0] = v.x[1][0];
1223 x[1][1] = v.x[1][1];
1238 constexpr
inline bool
1241 return x[0][0] == v.x[0][0] && x[0][1] == v.x[0][1] && x[1][0] == v.x[1][0] &&
1242 x[1][1] == v.x[1][1];
1246 constexpr
inline bool
1249 return x[0][0] != v.x[0][0] || x[0][1] != v.x[0][1] || x[1][0] != v.x[1][0] ||
1250 x[1][1] != v.x[1][1];
1254 ATOMSMATH_CONSTEXPR14
inline bool
1257 for (
int i = 0; i < 2; i++)
1258 for (
int j = 0; j < 2; j++)
1259 if (!ATOMSMATH_INTERNAL_NAMESPACE::equalWithAbsError ((*
this)[i][j], m[i][j], e))
1266 ATOMSMATH_CONSTEXPR14
inline bool
1269 for (
int i = 0; i < 2; i++)
1270 for (
int j = 0; j < 2; j++)
1271 if (!ATOMSMATH_INTERNAL_NAMESPACE::equalWithRelError ((*
this)[i][j], m[i][j], e))
1281 x[0][0] += v.
x[0][0];
1282 x[0][1] += v.x[0][1];
1283 x[1][0] += v.x[1][0];
1284 x[1][1] += v.x[1][1];
1305 return Matrix22 (x[0][0] + v.x[0][0],
1306 x[0][1] + v.x[0][1],
1307 x[1][0] + v.x[1][0],
1308 x[1][1] + v.x[1][1]);
1315 x[0][0] -= v.
x[0][0];
1316 x[0][1] -= v.x[0][1];
1317 x[1][0] -= v.x[1][0];
1318 x[1][1] -= v.x[1][1];
1339 return Matrix22 (x[0][0] - v.x[0][0],
1340 x[0][1] - v.x[0][1],
1341 x[1][0] - v.x[1][0],
1342 x[1][1] - v.x[1][1]);
1349 return Matrix22 (-x[0][0], -x[0][1], -x[1][0], -x[1][1]);
1380 return Matrix22 (x[0][0] * a, x[0][1] * a, x[1][0] * a, x[1][1] * a);
1397 for (
int i = 0; i < 2; i++)
1398 for (
int j = 0; j < 2; j++)
1399 for (
int k = 0; k < 2; k++)
1400 tmp.
x[i][j] += x[i][k] * v.x[k][j];
1412 for (
int i = 0; i < 2; i++)
1413 for (
int j = 0; j < 2; j++)
1414 for (
int k = 0; k < 2; k++)
1415 tmp.
x[i][j] += x[i][k] * v.x[k][j];
1427 a = src.x * x[0][0] + src.y * x[1][0];
1428 b = src.x * x[0][1] + src.y * x[1][1];
1450 return Matrix22 (x[0][0] / a, x[0][1] / a, x[1][0] / a, x[1][1] / a);
1457 Matrix22 tmp (x[0][0], x[1][0], x[0][1], x[1][1]);
1466 return Matrix22 (x[0][0], x[1][0], x[0][1], x[1][1]);
1473 *
this = inverse (singExc);
1489 Matrix22 s (x[1][1], -x[0][1], -x[1][0], x[0][0]);
1491 T r = x[0][0] * x[1][1] - x[1][0] * x[0][1];
1493 if (ATOMSMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
1495 for (
int i = 0; i < 2; ++i)
1497 for (
int j = 0; j < 2; ++j)
1505 T mr = ATOMSMATH_INTERNAL_NAMESPACE::abs (r) / std::numeric_limits<T>::min();
1507 for (
int i = 0; i < 2; ++i)
1509 for (
int j = 0; j < 2; ++j)
1511 if (mr > ATOMSMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
1517 #ifdef ATOMS_USE_EXCEPTIONS
1519 throw std::invalid_argument (
"Cannot invert "
1520 "singular matrix.");
1534 Matrix22 s (x[1][1], -x[0][1], -x[1][0], x[0][0]);
1536 T r = x[0][0] * x[1][1] - x[1][0] * x[0][1];
1538 if (ATOMSMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
1540 for (
int i = 0; i < 2; ++i)
1542 for (
int j = 0; j < 2; ++j)
1550 T mr = ATOMSMATH_INTERNAL_NAMESPACE::abs (r) / std::numeric_limits<T>::min();
1552 for (
int i = 0; i < 2; ++i)
1554 for (
int j = 0; j < 2; ++j)
1556 if (mr > ATOMSMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
1574 return x[0][0] * x[1][1] - x[1][0] * x[0][1];
1584 cos_r = cos ((T) r);
1585 sin_r = sin ((T) r);
1618 x[0][1] =
static_cast<T
> (0);
1619 x[1][0] =
static_cast<T
> (0);
1638 x[0][1] =
static_cast<T
> (0);
1639 x[1][0] =
static_cast<T
> (0);
1679 inline ATOMSMATH_CONSTEXPR14
1744 x[0][0] = v.x[0][0];
1745 x[0][1] = v.x[0][1];
1746 x[0][2] = v.x[0][2];
1747 x[1][0] = v.x[1][0];
1748 x[1][1] = v.x[1][1];
1749 x[1][2] = v.x[1][2];
1750 x[2][0] = v.x[2][0];
1751 x[2][1] = v.x[2][1];
1752 x[2][2] = v.x[2][2];
1760 x[0][0] = T (v.x[0][0]);
1761 x[0][1] = T (v.x[0][1]);
1762 x[0][2] = T (v.x[0][2]);
1763 x[1][0] = T (v.x[1][0]);
1764 x[1][1] = T (v.x[1][1]);
1765 x[1][2] = T (v.x[1][2]);
1766 x[2][0] = T (v.x[2][0]);
1767 x[2][1] = T (v.x[2][1]);
1768 x[2][2] = T (v.x[2][2]);
1780 x[0][0] = v.
x[0][0];
1781 x[0][1] = v.x[0][1];
1782 x[0][2] = v.x[0][2];
1783 x[1][0] = v.x[1][0];
1784 x[1][1] = v.x[1][1];
1785 x[1][2] = v.x[1][2];
1786 x[2][0] = v.x[2][0];
1787 x[2][1] = v.x[2][1];
1788 x[2][2] = v.x[2][2];
1813 return (T*) &x[0][0];
1820 return (
const T*) &x[0][0];
1828 v.x[0][0] = x[0][0];
1829 v.x[0][1] = x[0][1];
1830 v.x[0][2] = x[0][2];
1831 v.x[1][0] = x[1][0];
1832 v.x[1][1] = x[1][1];
1833 v.x[1][2] = x[1][2];
1834 v.x[2][0] = x[2][0];
1835 v.x[2][1] = x[2][1];
1836 v.x[2][2] = x[2][2];
1844 x[0][0] = v.
x[0][0];
1845 x[0][1] = v.x[0][1];
1846 x[0][2] = v.x[0][2];
1847 x[1][0] = v.x[1][0];
1848 x[1][1] = v.x[1][1];
1849 x[1][2] = v.x[1][2];
1850 x[2][0] = v.x[2][0];
1851 x[2][1] = v.x[2][1];
1852 x[2][2] = v.x[2][2];
1861 x[0][0] = v.
x[0][0];
1862 x[0][1] = v.x[0][1];
1863 x[0][2] = v.x[0][2];
1864 x[1][0] = v.x[1][0];
1865 x[1][1] = v.x[1][1];
1866 x[1][2] = v.x[1][2];
1867 x[2][0] = v.x[2][0];
1868 x[2][1] = v.x[2][1];
1869 x[2][2] = v.x[2][2];
1889 constexpr
inline bool
1892 return x[0][0] == v.x[0][0] && x[0][1] == v.x[0][1] && x[0][2] == v.x[0][2] &&
1893 x[1][0] == v.x[1][0] && x[1][1] == v.x[1][1] && x[1][2] == v.x[1][2] &&
1894 x[2][0] == v.x[2][0] && x[2][1] == v.x[2][1] && x[2][2] == v.x[2][2];
1898 constexpr
inline bool
1901 return x[0][0] != v.x[0][0] || x[0][1] != v.x[0][1] || x[0][2] != v.x[0][2] ||
1902 x[1][0] != v.x[1][0] || x[1][1] != v.x[1][1] || x[1][2] != v.x[1][2] ||
1903 x[2][0] != v.x[2][0] || x[2][1] != v.x[2][1] || x[2][2] != v.x[2][2];
1907 ATOMSMATH_CONSTEXPR14
inline bool
1910 for (
int i = 0; i < 3; i++)
1911 for (
int j = 0; j < 3; j++)
1912 if (!ATOMSMATH_INTERNAL_NAMESPACE::equalWithAbsError ((*
this)[i][j], m[i][j], e))
1919 ATOMSMATH_CONSTEXPR14
inline bool
1922 for (
int i = 0; i < 3; i++)
1923 for (
int j = 0; j < 3; j++)
1924 if (!ATOMSMATH_INTERNAL_NAMESPACE::equalWithRelError ((*
this)[i][j], m[i][j], e))
1934 x[0][0] += v.
x[0][0];
1935 x[0][1] += v.x[0][1];
1936 x[0][2] += v.x[0][2];
1937 x[1][0] += v.x[1][0];
1938 x[1][1] += v.x[1][1];
1939 x[1][2] += v.x[1][2];
1940 x[2][0] += v.x[2][0];
1941 x[2][1] += v.x[2][1];
1942 x[2][2] += v.x[2][2];
1968 return Matrix33 (x[0][0] + v.x[0][0],
1969 x[0][1] + v.x[0][1],
1970 x[0][2] + v.x[0][2],
1971 x[1][0] + v.x[1][0],
1972 x[1][1] + v.x[1][1],
1973 x[1][2] + v.x[1][2],
1974 x[2][0] + v.x[2][0],
1975 x[2][1] + v.x[2][1],
1976 x[2][2] + v.x[2][2]);
1983 x[0][0] -= v.
x[0][0];
1984 x[0][1] -= v.x[0][1];
1985 x[0][2] -= v.x[0][2];
1986 x[1][0] -= v.x[1][0];
1987 x[1][1] -= v.x[1][1];
1988 x[1][2] -= v.x[1][2];
1989 x[2][0] -= v.x[2][0];
1990 x[2][1] -= v.x[2][1];
1991 x[2][2] -= v.x[2][2];
2017 return Matrix33 (x[0][0] - v.x[0][0],
2018 x[0][1] - v.x[0][1],
2019 x[0][2] - v.x[0][2],
2020 x[1][0] - v.x[1][0],
2021 x[1][1] - v.x[1][1],
2022 x[1][2] - v.x[1][2],
2023 x[2][0] - v.x[2][0],
2024 x[2][1] - v.x[2][1],
2025 x[2][2] - v.x[2][2]);
2106 Matrix33 tmp (ATOMSMATH_NAMESPACE::UNINITIALIZED);
2108 tmp.
x[0][0] = x[0][0] * v.x[0][0] + x[0][1] * v.x[1][0] + x[0][2] * v.x[2][0];
2109 tmp.
x[0][1] = x[0][0] * v.x[0][1] + x[0][1] * v.x[1][1] + x[0][2] * v.x[2][1];
2110 tmp.
x[0][2] = x[0][0] * v.x[0][2] + x[0][1] * v.x[1][2] + x[0][2] * v.x[2][2];
2112 tmp.
x[1][0] = x[1][0] * v.x[0][0] + x[1][1] * v.x[1][0] + x[1][2] * v.x[2][0];
2113 tmp.
x[1][1] = x[1][0] * v.x[0][1] + x[1][1] * v.x[1][1] + x[1][2] * v.x[2][1];
2114 tmp.
x[1][2] = x[1][0] * v.x[0][2] + x[1][1] * v.x[1][2] + x[1][2] * v.x[2][2];
2116 tmp.
x[2][0] = x[2][0] * v.x[0][0] + x[2][1] * v.x[1][0] + x[2][2] * v.x[2][0];
2117 tmp.
x[2][1] = x[2][0] * v.x[0][1] + x[2][1] * v.x[1][1] + x[2][2] * v.x[2][1];
2118 tmp.
x[2][2] = x[2][0] * v.x[0][2] + x[2][1] * v.x[1][2] + x[2][2] * v.x[2][2];
2130 Matrix33 tmp (ATOMSMATH_NAMESPACE::UNINITIALIZED);
2132 tmp.
x[0][0] = x[0][0] * v.x[0][0] + x[0][1] * v.x[1][0] + x[0][2] * v.x[2][0];
2133 tmp.
x[0][1] = x[0][0] * v.x[0][1] + x[0][1] * v.x[1][1] + x[0][2] * v.x[2][1];
2134 tmp.
x[0][2] = x[0][0] * v.x[0][2] + x[0][1] * v.x[1][2] + x[0][2] * v.x[2][2];
2136 tmp.
x[1][0] = x[1][0] * v.x[0][0] + x[1][1] * v.x[1][0] + x[1][2] * v.x[2][0];
2137 tmp.
x[1][1] = x[1][0] * v.x[0][1] + x[1][1] * v.x[1][1] + x[1][2] * v.x[2][1];
2138 tmp.
x[1][2] = x[1][0] * v.x[0][2] + x[1][1] * v.x[1][2] + x[1][2] * v.x[2][2];
2140 tmp.
x[2][0] = x[2][0] * v.x[0][0] + x[2][1] * v.x[1][0] + x[2][2] * v.x[2][0];
2141 tmp.
x[2][1] = x[2][0] * v.x[0][1] + x[2][1] * v.x[1][1] + x[2][2] * v.x[2][1];
2142 tmp.
x[2][2] = x[2][0] * v.x[0][2] + x[2][1] * v.x[1][2] + x[2][2] * v.x[2][2];
2154 a = src.x * x[0][0] + src.y * x[1][0] + x[2][0];
2155 b = src.x * x[0][1] + src.y * x[1][1] + x[2][1];
2156 w = src.x * x[0][2] + src.y * x[1][2] + x[2][2];
2169 a = src.x * x[0][0] + src.y * x[1][0];
2170 b = src.x * x[0][1] + src.y * x[1][1];
2212 Matrix33 tmp (x[0][0], x[1][0], x[2][0], x[0][1], x[1][1], x[2][1], x[0][2], x[1][2], x[2][2]);
2236 *
this = gjInverse (singExc);
2244 *
this = gjInverse();
2258 for (i = 0; i < 2; i++)
2262 T pivotsize = t[i][i];
2265 pivotsize = -pivotsize;
2267 for (j = i + 1; j < 3; j++)
2274 if (tmp > pivotsize)
2283 #ifdef ATOMS_USE_EXCEPTIONS
2285 throw std::invalid_argument (
"Cannot invert singular matrix.");
2292 for (j = 0; j < 3; j++)
2297 t[i][j] = t[pivot][j];
2301 s[i][j] = s[pivot][j];
2306 for (j = i + 1; j < 3; j++)
2308 T f = t[j][i] / t[i][i];
2310 for (k = 0; k < 3; k++)
2312 t[j][k] -= f * t[i][k];
2313 s[j][k] -= f * s[i][k];
2320 for (i = 2; i >= 0; --i)
2324 if ((f = t[i][i]) == 0)
2326 #ifdef ATOMS_USE_EXCEPTIONS
2328 throw std::invalid_argument (
"Cannot invert singular matrix.");
2333 for (j = 0; j < 3; j++)
2339 for (j = 0; j < i; j++)
2343 for (k = 0; k < 3; k++)
2345 t[j][k] -= f * t[i][k];
2346 s[j][k] -= f * s[i][k];
2364 for (i = 0; i < 2; i++)
2368 T pivotsize = t[i][i];
2371 pivotsize = -pivotsize;
2373 for (j = i + 1; j < 3; j++)
2380 if (tmp > pivotsize)
2394 for (j = 0; j < 3; j++)
2399 t[i][j] = t[pivot][j];
2403 s[i][j] = s[pivot][j];
2408 for (j = i + 1; j < 3; j++)
2410 T f = t[j][i] / t[i][i];
2412 for (k = 0; k < 3; k++)
2414 t[j][k] -= f * t[i][k];
2415 s[j][k] -= f * s[i][k];
2422 for (i = 2; i >= 0; --i)
2426 if ((f = t[i][i]) == 0)
2431 for (j = 0; j < 3; j++)
2437 for (j = 0; j < i; j++)
2441 for (k = 0; k < 3; k++)
2443 t[j][k] -= f * t[i][k];
2444 s[j][k] -= f * s[i][k];
2456 *
this = inverse (singExc);
2472 if (x[0][2] != 0 || x[1][2] != 0 || x[2][2] != 1)
2474 Matrix33 s (x[1][1] * x[2][2] - x[2][1] * x[1][2],
2475 x[2][1] * x[0][2] - x[0][1] * x[2][2],
2476 x[0][1] * x[1][2] - x[1][1] * x[0][2],
2478 x[2][0] * x[1][2] - x[1][0] * x[2][2],
2479 x[0][0] * x[2][2] - x[2][0] * x[0][2],
2480 x[1][0] * x[0][2] - x[0][0] * x[1][2],
2482 x[1][0] * x[2][1] - x[2][0] * x[1][1],
2483 x[2][0] * x[0][1] - x[0][0] * x[2][1],
2484 x[0][0] * x[1][1] - x[1][0] * x[0][1]);
2486 T r = x[0][0] * s[0][0] + x[0][1] * s[1][0] + x[0][2] * s[2][0];
2488 if (ATOMSMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
2490 for (
int i = 0; i < 3; ++i)
2492 for (
int j = 0; j < 3; ++j)
2500 T mr = ATOMSMATH_INTERNAL_NAMESPACE::abs (r) / std::numeric_limits<T>::min();
2502 for (
int i = 0; i < 3; ++i)
2504 for (
int j = 0; j < 3; ++j)
2506 if (mr > ATOMSMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
2512 #ifdef ATOMS_USE_EXCEPTIONS
2514 throw std::invalid_argument (
"Cannot invert "
2515 "singular matrix.");
2539 T r = x[0][0] * x[1][1] - x[1][0] * x[0][1];
2541 if (ATOMSMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
2543 for (
int i = 0; i < 2; ++i)
2545 for (
int j = 0; j < 2; ++j)
2553 T mr = ATOMSMATH_INTERNAL_NAMESPACE::abs (r) / std::numeric_limits<T>::min();
2555 for (
int i = 0; i < 2; ++i)
2557 for (
int j = 0; j < 2; ++j)
2559 if (mr > ATOMSMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
2565 #ifdef ATOMS_USE_EXCEPTIONS
2567 throw std::invalid_argument (
"Cannot invert "
2568 "singular matrix.");
2576 s[2][0] = -x[2][0] * s[0][0] - x[2][1] * s[1][0];
2577 s[2][1] = -x[2][0] * s[0][1] - x[2][1] * s[1][1];
2587 if (x[0][2] != 0 || x[1][2] != 0 || x[2][2] != 1)
2589 Matrix33 s (x[1][1] * x[2][2] - x[2][1] * x[1][2],
2590 x[2][1] * x[0][2] - x[0][1] * x[2][2],
2591 x[0][1] * x[1][2] - x[1][1] * x[0][2],
2593 x[2][0] * x[1][2] - x[1][0] * x[2][2],
2594 x[0][0] * x[2][2] - x[2][0] * x[0][2],
2595 x[1][0] * x[0][2] - x[0][0] * x[1][2],
2597 x[1][0] * x[2][1] - x[2][0] * x[1][1],
2598 x[2][0] * x[0][1] - x[0][0] * x[2][1],
2599 x[0][0] * x[1][1] - x[1][0] * x[0][1]);
2601 T r = x[0][0] * s[0][0] + x[0][1] * s[1][0] + x[0][2] * s[2][0];
2603 if (ATOMSMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
2605 for (
int i = 0; i < 3; ++i)
2607 for (
int j = 0; j < 3; ++j)
2615 T mr = ATOMSMATH_INTERNAL_NAMESPACE::abs (r) / std::numeric_limits<T>::min();
2617 for (
int i = 0; i < 3; ++i)
2619 for (
int j = 0; j < 3; ++j)
2621 if (mr > ATOMSMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
2649 T r = x[0][0] * x[1][1] - x[1][0] * x[0][1];
2651 if (ATOMSMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
2653 for (
int i = 0; i < 2; ++i)
2655 for (
int j = 0; j < 2; ++j)
2663 T mr = ATOMSMATH_INTERNAL_NAMESPACE::abs (r) / std::numeric_limits<T>::min();
2665 for (
int i = 0; i < 2; ++i)
2667 for (
int j = 0; j < 2; ++j)
2669 if (mr > ATOMSMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
2681 s[2][0] = -x[2][0] * s[0][0] - x[2][1] * s[1][0];
2682 s[2][1] = -x[2][0] * s[0][1] - x[2][1] * s[1][1];
2689 ATOMSMATH_CONSTEXPR14
inline T
2692 int r0 = 0 + (r < 1 ? 1 : 0);
2693 int r1 = 1 + (r < 2 ? 1 : 0);
2694 int c0 = 0 + (c < 1 ? 1 : 0);
2695 int c1 = 1 + (c < 2 ? 1 : 0);
2697 return x[r0][c0] * x[r1][c1] - x[r1][c0] * x[r0][c1];
2704 return x[r0][c0] * x[r1][c1] - x[r0][c1] * x[r1][c0];
2711 return x[0][0] * (x[1][1] * x[2][2] - x[1][2] * x[2][1]) +
2712 x[0][1] * (x[1][2] * x[2][0] - x[1][0] * x[2][2]) +
2713 x[0][2] * (x[1][0] * x[2][1] - x[1][1] * x[2][0]);
2723 cos_r = cos ((T) r);
2724 sin_r = sin ((T) r);
2837 return Vec2<T> (x[2][0], x[2][1]);
2845 x[2][0] += t.
x * x[0][0] + t.y * x[1][0];
2846 x[2][1] += t.x * x[0][1] + t.y * x[1][1];
2847 x[2][2] += t.x * x[0][2] + t.y * x[1][2];
2903 x[1][0] += xy * x[0][0];
2904 x[1][1] += xy * x[0][1];
2905 x[1][2] += xy * x[0][2];
2917 x[0][0] = P[0][0] + h.y * P[1][0];
2918 x[0][1] = P[0][1] + h.y * P[1][1];
2919 x[0][2] = P[0][2] + h.y * P[1][2];
2921 x[1][0] = P[1][0] + h.x * P[0][0];
2922 x[1][1] = P[1][1] + h.x * P[0][1];
2923 x[1][2] = P[1][2] + h.x * P[0][2];
3007 ATOMSMATH_CONSTEXPR14
inline Matrix44<
3008 T>
::Matrix44 (T a, T b, T c, T d, T e, T f, T g, T h, T i, T j, T k, T l, T m, T n, T o, T p) noexcept
3050 x[0][0] = v.x[0][0];
3051 x[0][1] = v.x[0][1];
3052 x[0][2] = v.x[0][2];
3053 x[0][3] = v.x[0][3];
3054 x[1][0] = v.x[1][0];
3055 x[1][1] = v.x[1][1];
3056 x[1][2] = v.x[1][2];
3057 x[1][3] = v.x[1][3];
3058 x[2][0] = v.x[2][0];
3059 x[2][1] = v.x[2][1];
3060 x[2][2] = v.x[2][2];
3061 x[2][3] = v.x[2][3];
3062 x[3][0] = v.x[3][0];
3063 x[3][1] = v.x[3][1];
3064 x[3][2] = v.x[3][2];
3065 x[3][3] = v.x[3][3];
3072 x[0][0] = T (v.x[0][0]);
3073 x[0][1] = T (v.x[0][1]);
3074 x[0][2] = T (v.x[0][2]);
3075 x[0][3] = T (v.x[0][3]);
3076 x[1][0] = T (v.x[1][0]);
3077 x[1][1] = T (v.x[1][1]);
3078 x[1][2] = T (v.x[1][2]);
3079 x[1][3] = T (v.x[1][3]);
3080 x[2][0] = T (v.x[2][0]);
3081 x[2][1] = T (v.x[2][1]);
3082 x[2][2] = T (v.x[2][2]);
3083 x[2][3] = T (v.x[2][3]);
3084 x[3][0] = T (v.x[3][0]);
3085 x[3][1] = T (v.x[3][1]);
3086 x[3][2] = T (v.x[3][2]);
3087 x[3][3] = T (v.x[3][3]);
3094 x[0][0] = v.
x[0][0];
3095 x[0][1] = v.x[0][1];
3096 x[0][2] = v.x[0][2];
3097 x[0][3] = v.x[0][3];
3098 x[1][0] = v.x[1][0];
3099 x[1][1] = v.x[1][1];
3100 x[1][2] = v.x[1][2];
3101 x[1][3] = v.x[1][3];
3102 x[2][0] = v.x[2][0];
3103 x[2][1] = v.x[2][1];
3104 x[2][2] = v.x[2][2];
3105 x[2][3] = v.x[2][3];
3106 x[3][0] = v.x[3][0];
3107 x[3][1] = v.x[3][1];
3108 x[3][2] = v.x[3][2];
3109 x[3][3] = v.x[3][3];
3140 return (T*) &x[0][0];
3147 return (
const T*) &x[0][0];
3155 v.x[0][0] = x[0][0];
3156 v.x[0][1] = x[0][1];
3157 v.x[0][2] = x[0][2];
3158 v.x[0][3] = x[0][3];
3159 v.x[1][0] = x[1][0];
3160 v.x[1][1] = x[1][1];
3161 v.x[1][2] = x[1][2];
3162 v.x[1][3] = x[1][3];
3163 v.x[2][0] = x[2][0];
3164 v.x[2][1] = x[2][1];
3165 v.x[2][2] = x[2][2];
3166 v.x[2][3] = x[2][3];
3167 v.x[3][0] = x[3][0];
3168 v.x[3][1] = x[3][1];
3169 v.x[3][2] = x[3][2];
3170 v.x[3][3] = x[3][3];
3178 x[0][0] = v.
x[0][0];
3179 x[0][1] = v.x[0][1];
3180 x[0][2] = v.x[0][2];
3181 x[0][3] = v.x[0][3];
3182 x[1][0] = v.x[1][0];
3183 x[1][1] = v.x[1][1];
3184 x[1][2] = v.x[1][2];
3185 x[1][3] = v.x[1][3];
3186 x[2][0] = v.x[2][0];
3187 x[2][1] = v.x[2][1];
3188 x[2][2] = v.x[2][2];
3189 x[2][3] = v.x[2][3];
3190 x[3][0] = v.x[3][0];
3191 x[3][1] = v.x[3][1];
3192 x[3][2] = v.x[3][2];
3193 x[3][3] = v.x[3][3];
3202 x[0][0] = v.
x[0][0];
3203 x[0][1] = v.x[0][1];
3204 x[0][2] = v.x[0][2];
3205 x[0][3] = v.x[0][3];
3206 x[1][0] = v.x[1][0];
3207 x[1][1] = v.x[1][1];
3208 x[1][2] = v.x[1][2];
3209 x[1][3] = v.x[1][3];
3210 x[2][0] = v.x[2][0];
3211 x[2][1] = v.x[2][1];
3212 x[2][2] = v.x[2][2];
3213 x[2][3] = v.x[2][3];
3214 x[3][0] = v.x[3][0];
3215 x[3][1] = v.x[3][1];
3216 x[3][2] = v.x[3][2];
3217 x[3][3] = v.x[3][3];
3244 constexpr
inline bool
3247 return x[0][0] == v.x[0][0] && x[0][1] == v.x[0][1] && x[0][2] == v.x[0][2] &&
3248 x[0][3] == v.x[0][3] && x[1][0] == v.x[1][0] && x[1][1] == v.x[1][1] &&
3249 x[1][2] == v.x[1][2] && x[1][3] == v.x[1][3] && x[2][0] == v.x[2][0] &&
3250 x[2][1] == v.x[2][1] && x[2][2] == v.x[2][2] && x[2][3] == v.x[2][3] &&
3251 x[3][0] == v.x[3][0] && x[3][1] == v.x[3][1] && x[3][2] == v.x[3][2] &&
3252 x[3][3] == v.x[3][3];
3256 constexpr
inline bool
3259 return x[0][0] != v.x[0][0] || x[0][1] != v.x[0][1] || x[0][2] != v.x[0][2] ||
3260 x[0][3] != v.x[0][3] || x[1][0] != v.x[1][0] || x[1][1] != v.x[1][1] ||
3261 x[1][2] != v.x[1][2] || x[1][3] != v.x[1][3] || x[2][0] != v.x[2][0] ||
3262 x[2][1] != v.x[2][1] || x[2][2] != v.x[2][2] || x[2][3] != v.x[2][3] ||
3263 x[3][0] != v.x[3][0] || x[3][1] != v.x[3][1] || x[3][2] != v.x[3][2] ||
3264 x[3][3] != v.x[3][3];
3268 ATOMSMATH_CONSTEXPR14
inline bool
3271 for (
int i = 0; i < 4; i++)
3272 for (
int j = 0; j < 4; j++)
3273 if (!ATOMSMATH_INTERNAL_NAMESPACE::equalWithAbsError ((*
this)[i][j], m[i][j], e))
3280 ATOMSMATH_CONSTEXPR14
inline bool
3283 for (
int i = 0; i < 4; i++)
3284 for (
int j = 0; j < 4; j++)
3285 if (!ATOMSMATH_INTERNAL_NAMESPACE::equalWithRelError ((*
this)[i][j], m[i][j], e))
3295 x[0][0] += v.
x[0][0];
3296 x[0][1] += v.x[0][1];
3297 x[0][2] += v.x[0][2];
3298 x[0][3] += v.x[0][3];
3299 x[1][0] += v.x[1][0];
3300 x[1][1] += v.x[1][1];
3301 x[1][2] += v.x[1][2];
3302 x[1][3] += v.x[1][3];
3303 x[2][0] += v.x[2][0];
3304 x[2][1] += v.x[2][1];
3305 x[2][2] += v.x[2][2];
3306 x[2][3] += v.x[2][3];
3307 x[3][0] += v.x[3][0];
3308 x[3][1] += v.x[3][1];
3309 x[3][2] += v.x[3][2];
3310 x[3][3] += v.x[3][3];
3343 return Matrix44 (x[0][0] + v.x[0][0],
3344 x[0][1] + v.x[0][1],
3345 x[0][2] + v.x[0][2],
3346 x[0][3] + v.x[0][3],
3347 x[1][0] + v.x[1][0],
3348 x[1][1] + v.x[1][1],
3349 x[1][2] + v.x[1][2],
3350 x[1][3] + v.x[1][3],
3351 x[2][0] + v.x[2][0],
3352 x[2][1] + v.x[2][1],
3353 x[2][2] + v.x[2][2],
3354 x[2][3] + v.x[2][3],
3355 x[3][0] + v.x[3][0],
3356 x[3][1] + v.x[3][1],
3357 x[3][2] + v.x[3][2],
3358 x[3][3] + v.x[3][3]);
3365 x[0][0] -= v.
x[0][0];
3366 x[0][1] -= v.x[0][1];
3367 x[0][2] -= v.x[0][2];
3368 x[0][3] -= v.x[0][3];
3369 x[1][0] -= v.x[1][0];
3370 x[1][1] -= v.x[1][1];
3371 x[1][2] -= v.x[1][2];
3372 x[1][3] -= v.x[1][3];
3373 x[2][0] -= v.x[2][0];
3374 x[2][1] -= v.x[2][1];
3375 x[2][2] -= v.x[2][2];
3376 x[2][3] -= v.x[2][3];
3377 x[3][0] -= v.x[3][0];
3378 x[3][1] -= v.x[3][1];
3379 x[3][2] -= v.x[3][2];
3380 x[3][3] -= v.x[3][3];
3413 return Matrix44 (x[0][0] - v.x[0][0],
3414 x[0][1] - v.x[0][1],
3415 x[0][2] - v.x[0][2],
3416 x[0][3] - v.x[0][3],
3417 x[1][0] - v.x[1][0],
3418 x[1][1] - v.x[1][1],
3419 x[1][2] - v.x[1][2],
3420 x[1][3] - v.x[1][3],
3421 x[2][0] - v.x[2][0],
3422 x[2][1] - v.x[2][1],
3423 x[2][2] - v.x[2][2],
3424 x[2][3] - v.x[2][3],
3425 x[3][0] - v.x[3][0],
3426 x[3][1] - v.x[3][1],
3427 x[3][2] - v.x[3][2],
3428 x[3][3] - v.x[3][3]);
3537 multiply (*
this, v, tmp);
3548 multiply (*
this, v, tmp);
3556 const T* ATOMSMATH_RESTRICT ap = &a.x[0][0];
3557 const T* ATOMSMATH_RESTRICT bp = &b.x[0][0];
3558 T* ATOMSMATH_RESTRICT cp = &c.x[0][0];
3567 cp[0] = a0 * bp[0] + a1 * bp[4] + a2 * bp[8] + a3 * bp[12];
3568 cp[1] = a0 * bp[1] + a1 * bp[5] + a2 * bp[9] + a3 * bp[13];
3569 cp[2] = a0 * bp[2] + a1 * bp[6] + a2 * bp[10] + a3 * bp[14];
3570 cp[3] = a0 * bp[3] + a1 * bp[7] + a2 * bp[11] + a3 * bp[15];
3577 cp[4] = a0 * bp[0] + a1 * bp[4] + a2 * bp[8] + a3 * bp[12];
3578 cp[5] = a0 * bp[1] + a1 * bp[5] + a2 * bp[9] + a3 * bp[13];
3579 cp[6] = a0 * bp[2] + a1 * bp[6] + a2 * bp[10] + a3 * bp[14];
3580 cp[7] = a0 * bp[3] + a1 * bp[7] + a2 * bp[11] + a3 * bp[15];
3587 cp[8] = a0 * bp[0] + a1 * bp[4] + a2 * bp[8] + a3 * bp[12];
3588 cp[9] = a0 * bp[1] + a1 * bp[5] + a2 * bp[9] + a3 * bp[13];
3589 cp[10] = a0 * bp[2] + a1 * bp[6] + a2 * bp[10] + a3 * bp[14];
3590 cp[11] = a0 * bp[3] + a1 * bp[7] + a2 * bp[11] + a3 * bp[15];
3597 cp[12] = a0 * bp[0] + a1 * bp[4] + a2 * bp[8] + a3 * bp[12];
3598 cp[13] = a0 * bp[1] + a1 * bp[5] + a2 * bp[9] + a3 * bp[13];
3599 cp[14] = a0 * bp[2] + a1 * bp[6] + a2 * bp[10] + a3 * bp[14];
3600 cp[15] = a0 * bp[3] + a1 * bp[7] + a2 * bp[11] + a3 * bp[15];
3610 a = src.x * x[0][0] + src.y * x[1][0] + src.z * x[2][0] + x[3][0];
3611 b = src.x * x[0][1] + src.y * x[1][1] + src.z * x[2][1] + x[3][1];
3612 c = src.x * x[0][2] + src.y * x[1][2] + src.z * x[2][2] + x[3][2];
3613 w = src.x * x[0][3] + src.y * x[1][3] + src.z * x[2][3] + x[3][3];
3627 a = src.x * x[0][0] + src.y * x[1][0] + src.z * x[2][0];
3628 b = src.x * x[0][1] + src.y * x[1][1] + src.z * x[2][1];
3629 c = src.x * x[0][2] + src.y * x[1][2] + src.z * x[2][2];
3732 *
this = gjInverse (singExc);
3740 *
this = gjInverse();
3754 for (i = 0; i < 3; i++)
3758 T pivotsize = t[i][i];
3761 pivotsize = -pivotsize;
3763 for (j = i + 1; j < 4; j++)
3770 if (tmp > pivotsize)
3779 #ifdef ATOMS_USE_EXCEPTIONS
3781 throw std::invalid_argument (
"Cannot invert singular matrix.");
3788 for (j = 0; j < 4; j++)
3793 t[i][j] = t[pivot][j];
3797 s[i][j] = s[pivot][j];
3802 for (j = i + 1; j < 4; j++)
3804 T f = t[j][i] / t[i][i];
3806 for (k = 0; k < 4; k++)
3808 t[j][k] -= f * t[i][k];
3809 s[j][k] -= f * s[i][k];
3816 for (i = 3; i >= 0; --i)
3820 if ((f = t[i][i]) == 0)
3822 #ifdef ATOMS_USE_EXCEPTIONS
3824 throw std::invalid_argument (
"Cannot invert singular matrix.");
3829 for (j = 0; j < 4; j++)
3835 for (j = 0; j < i; j++)
3839 for (k = 0; k < 4; k++)
3841 t[j][k] -= f * t[i][k];
3842 s[j][k] -= f * s[i][k];
3860 for (i = 0; i < 3; i++)
3864 T pivotsize = t[i][i];
3867 pivotsize = -pivotsize;
3869 for (j = i + 1; j < 4; j++)
3876 if (tmp > pivotsize)
3890 for (j = 0; j < 4; j++)
3895 t[i][j] = t[pivot][j];
3899 s[i][j] = s[pivot][j];
3904 for (j = i + 1; j < 4; j++)
3906 T f = t[j][i] / t[i][i];
3908 for (k = 0; k < 4; k++)
3910 t[j][k] -= f * t[i][k];
3911 s[j][k] -= f * s[i][k];
3918 for (i = 3; i >= 0; --i)
3922 if ((f = t[i][i]) == 0)
3927 for (j = 0; j < 4; j++)
3933 for (j = 0; j < i; j++)
3937 for (k = 0; k < 4; k++)
3939 t[j][k] -= f * t[i][k];
3940 s[j][k] -= f * s[i][k];
3952 *
this = inverse (singExc);
3968 if (x[0][3] != 0 || x[1][3] != 0 || x[2][3] != 0 || x[3][3] != 1)
3969 return gjInverse (singExc);
3971 Matrix44 s (x[1][1] * x[2][2] - x[2][1] * x[1][2],
3972 x[2][1] * x[0][2] - x[0][1] * x[2][2],
3973 x[0][1] * x[1][2] - x[1][1] * x[0][2],
3976 x[2][0] * x[1][2] - x[1][0] * x[2][2],
3977 x[0][0] * x[2][2] - x[2][0] * x[0][2],
3978 x[1][0] * x[0][2] - x[0][0] * x[1][2],
3981 x[1][0] * x[2][1] - x[2][0] * x[1][1],
3982 x[2][0] * x[0][1] - x[0][0] * x[2][1],
3983 x[0][0] * x[1][1] - x[1][0] * x[0][1],
3991 T r = x[0][0] * s[0][0] + x[0][1] * s[1][0] + x[0][2] * s[2][0];
3993 if (ATOMSMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
3995 for (
int i = 0; i < 3; ++i)
3997 for (
int j = 0; j < 3; ++j)
4005 T mr = ATOMSMATH_INTERNAL_NAMESPACE::abs (r) / std::numeric_limits<T>::min();
4007 for (
int i = 0; i < 3; ++i)
4009 for (
int j = 0; j < 3; ++j)
4011 if (mr > ATOMSMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
4017 #ifdef ATOMS_USE_EXCEPTIONS
4019 throw std::invalid_argument (
"Cannot invert singular matrix.");
4027 s[3][0] = -x[3][0] * s[0][0] - x[3][1] * s[1][0] - x[3][2] * s[2][0];
4028 s[3][1] = -x[3][0] * s[0][1] - x[3][1] * s[1][1] - x[3][2] * s[2][1];
4029 s[3][2] = -x[3][0] * s[0][2] - x[3][1] * s[1][2] - x[3][2] * s[2][2];
4038 if (x[0][3] != 0 || x[1][3] != 0 || x[2][3] != 0 || x[3][3] != 1)
4041 Matrix44 s (x[1][1] * x[2][2] - x[2][1] * x[1][2],
4042 x[2][1] * x[0][2] - x[0][1] * x[2][2],
4043 x[0][1] * x[1][2] - x[1][1] * x[0][2],
4046 x[2][0] * x[1][2] - x[1][0] * x[2][2],
4047 x[0][0] * x[2][2] - x[2][0] * x[0][2],
4048 x[1][0] * x[0][2] - x[0][0] * x[1][2],
4051 x[1][0] * x[2][1] - x[2][0] * x[1][1],
4052 x[2][0] * x[0][1] - x[0][0] * x[2][1],
4053 x[0][0] * x[1][1] - x[1][0] * x[0][1],
4061 T r = x[0][0] * s[0][0] + x[0][1] * s[1][0] + x[0][2] * s[2][0];
4063 if (ATOMSMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
4065 for (
int i = 0; i < 3; ++i)
4067 for (
int j = 0; j < 3; ++j)
4075 T mr = ATOMSMATH_INTERNAL_NAMESPACE::abs (r) / std::numeric_limits<T>::min();
4077 for (
int i = 0; i < 3; ++i)
4079 for (
int j = 0; j < 3; ++j)
4081 if (mr > ATOMSMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
4093 s[3][0] = -x[3][0] * s[0][0] - x[3][1] * s[1][0] - x[3][2] * s[2][0];
4094 s[3][1] = -x[3][0] * s[0][1] - x[3][1] * s[1][1] - x[3][2] * s[2][1];
4095 s[3][2] = -x[3][0] * s[0][2] - x[3][1] * s[1][2] - x[3][2] * s[2][2];
4107 const int c2)
const noexcept
4109 return x[r0][c0] * (x[r1][c1] * x[r2][c2] - x[r1][c2] * x[r2][c1]) +
4110 x[r0][c1] * (x[r1][c2] * x[r2][c0] - x[r1][c0] * x[r2][c2]) +
4111 x[r0][c2] * (x[r1][c0] * x[r2][c1] - x[r1][c1] * x[r2][c0]);
4115 ATOMSMATH_CONSTEXPR14
inline T
4118 int r0 = 0 + (r < 1 ? 1 : 0);
4119 int r1 = 1 + (r < 2 ? 1 : 0);
4120 int r2 = 2 + (r < 3 ? 1 : 0);
4121 int c0 = 0 + (c < 1 ? 1 : 0);
4122 int c1 = 1 + (c < 2 ? 1 : 0);
4123 int c2 = 2 + (c < 3 ? 1 : 0);
4139 ATOMSMATH_CONSTEXPR14
inline T
4145 sum -= x[0][3] * fastMinor (1, 2, 3, 0, 1, 2);
4147 sum += x[1][3] * fastMinor (0, 2, 3, 0, 1, 2);
4149 sum -= x[2][3] * fastMinor (0, 1, 3, 0, 1, 2);
4151 sum += x[3][3] * fastMinor (0, 1, 2, 0, 1, 2);
4161 S cos_rz, sin_rz, cos_ry, sin_ry, cos_rx, sin_rx;
4163 cos_rz = cos ((T) r.z);
4164 cos_ry = cos ((T) r.y);
4165 cos_rx = cos ((T) r.x);
4167 sin_rz = sin ((T) r.z);
4168 sin_ry = sin ((T) r.y);
4169 sin_rx = sin ((T) r.x);
4171 x[0][0] = cos_rz * cos_ry;
4172 x[0][1] = sin_rz * cos_ry;
4176 x[1][0] = -sin_rz * cos_rx + cos_rz * sin_ry * sin_rx;
4177 x[1][1] = cos_rz * cos_rx + sin_rz * sin_ry * sin_rx;
4178 x[1][2] = cos_ry * sin_rx;
4181 x[2][0] = sin_rz * sin_rx + cos_rz * sin_ry * cos_rx;
4182 x[2][1] = -cos_rz * sin_rx + sin_rz * sin_ry * cos_rx;
4183 x[2][2] = cos_ry * cos_rx;
4199 Vec3<S> unit (axis.normalized());
4200 S sine = std::sin (angle);
4201 S cosine = std::cos (angle);
4203 x[0][0] = unit.x * unit.x * (1 - cosine) + cosine;
4204 x[0][1] = unit.x * unit.y * (1 - cosine) + unit.z * sine;
4205 x[0][2] = unit.x * unit.z * (1 - cosine) - unit.y * sine;
4208 x[1][0] = unit.x * unit.y * (1 - cosine) - unit.z * sine;
4209 x[1][1] = unit.y * unit.y * (1 - cosine) + cosine;
4210 x[1][2] = unit.y * unit.z * (1 - cosine) + unit.x * sine;
4213 x[2][0] = unit.x * unit.z * (1 - cosine) + unit.y * sine;
4214 x[2][1] = unit.y * unit.z * (1 - cosine) - unit.x * sine;
4215 x[2][2] = unit.z * unit.z * (1 - cosine) + cosine;
4231 S cos_rz, sin_rz, cos_ry, sin_ry, cos_rx, sin_rx;
4236 cos_rz = cos ((S) r.z);
4237 cos_ry = cos ((S) r.y);
4238 cos_rx = cos ((S) r.x);
4240 sin_rz = sin ((S) r.z);
4241 sin_ry = sin ((S) r.y);
4242 sin_rx = sin ((S) r.x);
4244 m00 = cos_rz * cos_ry;
4245 m01 = sin_rz * cos_ry;
4247 m10 = -sin_rz * cos_rx + cos_rz * sin_ry * sin_rx;
4248 m11 = cos_rz * cos_rx + sin_rz * sin_ry * sin_rx;
4249 m12 = cos_ry * sin_rx;
4250 m20 = -sin_rz * -sin_rx + cos_rz * sin_ry * cos_rx;
4251 m21 = cos_rz * -sin_rx + sin_rz * sin_ry * cos_rx;
4252 m22 = cos_ry * cos_rx;
4256 x[0][0] = P[0][0] * m00 + P[1][0] * m01 + P[2][0] * m02;
4257 x[0][1] = P[0][1] * m00 + P[1][1] * m01 + P[2][1] * m02;
4258 x[0][2] = P[0][2] * m00 + P[1][2] * m01 + P[2][2] * m02;
4259 x[0][3] = P[0][3] * m00 + P[1][3] * m01 + P[2][3] * m02;
4261 x[1][0] = P[0][0] * m10 + P[1][0] * m11 + P[2][0] * m12;
4262 x[1][1] = P[0][1] * m10 + P[1][1] * m11 + P[2][1] * m12;
4263 x[1][2] = P[0][2] * m10 + P[1][2] * m11 + P[2][2] * m12;
4264 x[1][3] = P[0][3] * m10 + P[1][3] * m11 + P[2][3] * m12;
4266 x[2][0] = P[0][0] * m20 + P[1][0] * m21 + P[2][0] * m22;
4267 x[2][1] = P[0][1] * m20 + P[1][1] * m21 + P[2][1] * m22;
4268 x[2][2] = P[0][2] * m20 + P[1][2] * m21 + P[2][2] * m22;
4269 x[2][3] = P[0][3] * m20 + P[1][3] * m21 + P[2][3] * m22;
4389 constexpr
inline const Vec3<T>
4392 return Vec3<T> (x[3][0], x[3][1], x[3][2]);
4400 x[3][0] += t.
x * x[0][0] + t.y * x[1][0] + t.z * x[2][0];
4401 x[3][1] += t.x * x[0][1] + t.y * x[1][1] + t.z * x[2][1];
4402 x[3][2] += t.x * x[0][2] + t.y * x[1][2] + t.z * x[2][2];
4403 x[3][3] += t.x * x[0][3] + t.y * x[1][3] + t.z * x[2][3];
4475 for (
int i = 0; i < 4; i++)
4477 x[2][i] += h.y * x[0][i] + h.z * x[1][i];
4478 x[1][i] += h.
x * x[0][i];
4491 for (
int i = 0; i < 4; i++)
4493 x[0][i] = P[0][i] + h.yx * P[1][i] + h.zx * P[2][i];
4494 x[1][i] = h.xy * P[0][i] + P[1][i] + h.zy * P[2][i];
4495 x[2][i] = h.xz * P[0][i] + h.yz * P[1][i] + P[2][i];
4507 operator<< (std::ostream& s,
const Matrix22<T>& m)
4509 std::ios_base::fmtflags oldFlags = s.flags();
4512 if (s.flags() & std::ios_base::fixed)
4514 s.setf (std::ios_base::showpoint);
4515 width =
static_cast<int> (s.precision()) + 5;
4519 s.setf (std::ios_base::scientific);
4520 s.setf (std::ios_base::showpoint);
4521 width =
static_cast<int> (s.precision()) + 8;
4524 s <<
"(" << std::setw (width) << m[0][0] <<
", " << std::setw (width) << m[0][1] <<
",\n"
4527 " " << std::setw (width) << m[1][0] <<
", " << std::setw (width) << m[1][1] <<
")\n";
4535 operator<< (std::ostream& s,
const Matrix33<T>& m)
4537 std::ios_base::fmtflags oldFlags = s.flags();
4540 if (s.flags() & std::ios_base::fixed)
4542 s.setf (std::ios_base::showpoint);
4543 width =
static_cast<int> (s.precision()) + 5;
4547 s.setf (std::ios_base::scientific);
4548 s.setf (std::ios_base::showpoint);
4549 width =
static_cast<int> (s.precision()) + 8;
4552 s <<
"(" << std::setw (width) << m[0][0] <<
", " << std::setw (width) << m[0][1] <<
", "
4553 << std::setw (width) << m[0][2] <<
",\n"
4556 " " << std::setw (width) << m[1][0] <<
", " << std::setw (width) << m[1][1] <<
", "
4557 << std::setw (width) << m[1][2] <<
",\n"
4560 " " << std::setw (width) << m[2][0] <<
", " << std::setw (width) << m[2][1] <<
", "
4561 << std::setw (width) << m[2][2] <<
")\n";
4569 operator<< (std::ostream& s,
const Matrix44<T>& m)
4571 std::ios_base::fmtflags oldFlags = s.flags();
4574 if (s.flags() & std::ios_base::fixed)
4576 s.setf (std::ios_base::showpoint);
4577 width =
static_cast<int> (s.precision()) + 5;
4581 s.setf (std::ios_base::scientific);
4582 s.setf (std::ios_base::showpoint);
4583 width =
static_cast<int> (s.precision()) + 8;
4586 s <<
"(" << std::setw (width) << m[0][0] <<
", " << std::setw (width) << m[0][1] <<
", "
4587 << std::setw (width) << m[0][2] <<
", " << std::setw (width) << m[0][3] <<
",\n"
4590 " " << std::setw (width) << m[1][0] <<
", " << std::setw (width) << m[1][1] <<
", "
4591 << std::setw (width) << m[1][2] <<
", " << std::setw (width) << m[1][3] <<
",\n"
4594 " " << std::setw (width) << m[2][0] <<
", " << std::setw (width) << m[2][1] <<
", "
4595 << std::setw (width) << m[2][2] <<
", " << std::setw (width) << m[2][3] <<
",\n"
4598 " " << std::setw (width) << m[3][0] <<
", " << std::setw (width) << m[3][1] <<
", "
4599 << std::setw (width) << m[3][2] <<
", " << std::setw (width) << m[3][3] <<
")\n";
4609 template <
class S,
class T>
4613 S x = S (v.x * m[0][0] + v.y * m[1][0]);
4614 S y = S (v.x * m[0][1] + v.y * m[1][1]);
4622 template <
class S,
class T>
4626 S x = S (v.x * m[0][0] + v.y * m[1][0]);
4627 S y = S (v.x * m[0][1] + v.y * m[1][1]);
4632 template <
class S,
class T>
4636 S x = S (v.x * m[0][0] + v.y * m[1][0] + m[2][0]);
4637 S y = S (v.x * m[0][1] + v.y * m[1][1] + m[2][1]);
4638 S w = S (v.x * m[0][2] + v.y * m[1][2] + m[2][2]);
4646 template <
class S,
class T>
4650 S x = S (v.x * m[0][0] + v.y * m[1][0] + m[2][0]);
4651 S y = S (v.x * m[0][1] + v.y * m[1][1] + m[2][1]);
4652 S w = S (v.x * m[0][2] + v.y * m[1][2] + m[2][2]);
4654 return Vec2<S> (x / w, y / w);
4657 template <
class S,
class T>
4661 S x = S (v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0]);
4662 S y = S (v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1]);
4663 S z = S (v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2]);
4672 template <
class S,
class T>
4676 S x = S (v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0]);
4677 S y = S (v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1]);
4678 S z = S (v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2]);
4683 template <
class S,
class T>
4687 S x = S (v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0]);
4688 S y = S (v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1]);
4689 S z = S (v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]);
4690 S w = S (v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + m[3][3]);
4699 template <
class S,
class T>
4703 S x = S (v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0]);
4704 S y = S (v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1]);
4705 S z = S (v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]);
4706 S w = S (v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + m[3][3]);
4708 return Vec3<S> (x / w, y / w, z / w);
4711 template <
class S,
class T>
4715 S x = S (v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + v.w * m[3][0]);
4716 S y = S (v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + v.w * m[3][1]);
4717 S z = S (v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + v.w * m[3][2]);
4718 S w = S (v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + v.w * m[3][3]);
4728 template <
class S,
class T>
4732 S x = S (v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + v.w * m[3][0]);
4733 S y = S (v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + v.w * m[3][1]);
4734 S z = S (v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + v.w * m[3][2]);
4735 S w = S (v.x * m[0][3] + v.y * m[1][3] + v.z * m[2][3] + v.w * m[3][3]);
4740 ATOMSMATH_INTERNAL_NAMESPACE_HEADER_EXIT
Definition: ImathMatrix.h:44
ATOMSMATH_HOSTDEVICE void multDirMatrix(const Vec2< S > &src, Vec2< S > &dst) const noexcept
constexpr ATOMSMATH_HOSTDEVICE Matrix22 operator-() const noexcept
Component-wise multiplication by -1.
Definition: ImathMatrix.h:1347
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix22 & operator+=(const Matrix22 &v) noexcept
Component-wise addition.
Definition: ImathMatrix.h:1279
Vec2< T > BaseVecType
The base vector type.
Definition: ImathMatrix.h:280
constexpr ATOMSMATH_HOSTDEVICE Matrix22 transposed() const noexcept
Return the transpose.
Definition: ImathMatrix.h:1464
ATOMSMATH_HOSTDEVICE T * getValue() noexcept
Return a raw pointer to the array of values.
Definition: ImathMatrix.h:1180
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool equalWithRelError(const Matrix22< T > &v, T e) const noexcept
Definition: ImathMatrix.h:1267
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeMax() noexcept
Largest possible positive value.
Definition: ImathMatrix.h:262
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix22 & invert() noexcept
Definition: ImathMatrix.h:1479
constexpr ATOMSMATH_HOSTDEVICE Matrix22 operator+(const Matrix22 &v) const noexcept
Component-wise addition.
Definition: ImathMatrix.h:1303
constexpr ATOMSMATH_HOSTDEVICE Matrix22 operator/(T a) const noexcept
Component-wise division.
Definition: ImathMatrix.h:1448
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix22< T > inverse() const noexcept
Return the inverse, leaving this unmodified.
Definition: ImathMatrix.h:1532
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix22() noexcept
Uninitialized.
Definition: ImathMatrix.h:1094
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix22 & transpose() noexcept
Transpose.
Definition: ImathMatrix.h:1455
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeSmallest() noexcept
Smallest possible positive value.
Definition: ImathMatrix.h:265
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix22 & setTheMatrix(const Matrix22< S > &v) noexcept
Set the value.
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix22 & setValue(const Matrix22< S > &v) noexcept
Set the value.
constexpr ATOMSMATH_HOSTDEVICE Matrix22 operator*(T a) const noexcept
Component-wise multiplication.
Definition: ImathMatrix.h:1378
constexpr static ATOMSMATH_HOSTDEVICE unsigned int dimensions() noexcept
Return the number of the row and column dimensions, i.e. 2.
Definition: ImathMatrix.h:273
ATOMSMATH_HOSTDEVICE T * operator[](int i) noexcept
Row access.
Definition: ImathMatrix.h:1082
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix22 & operator/=(T a) noexcept
Component-wise division.
Definition: ImathMatrix.h:1436
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool equalWithAbsError(const Matrix22< T > &v, T e) const noexcept
Definition: ImathMatrix.h:1255
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix22 & rotate(S r) noexcept
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix22 & setScale(T s) noexcept
Definition: ImathMatrix.h:1609
T x[2][2]
Matrix elements.
Definition: ImathMatrix.h:51
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix22 & negate() noexcept
Component-wise multiplication by -1.
Definition: ImathMatrix.h:1354
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix22 & operator*=(T a) noexcept
Component-wise multiplication.
Definition: ImathMatrix.h:1366
constexpr ATOMSMATH_HOSTDEVICE bool operator!=(const Matrix22 &v) const noexcept
Inequality.
Definition: ImathMatrix.h:1247
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix22 & operator=(const Matrix22 &v) noexcept
Assignment.
Definition: ImathMatrix.h:1154
T BaseType
Definition: ImathMatrix.h:277
ATOMSMATH_HOSTDEVICE const Matrix22 & setRotation(S r) noexcept
constexpr ATOMSMATH_HOSTDEVICE T determinant() const noexcept
Determinant.
Definition: ImathMatrix.h:1572
ATOMSMATH_HOSTDEVICE void makeIdentity() noexcept
Set to the identity.
Definition: ImathMatrix.h:1229
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix22 & operator-=(const Matrix22 &v) noexcept
Component-wise subtraction.
Definition: ImathMatrix.h:1313
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeLowest() noexcept
Largest possible negative value.
Definition: ImathMatrix.h:259
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeEpsilon() noexcept
Smallest possible e for which 1+e != 1.
Definition: ImathMatrix.h:268
constexpr ATOMSMATH_HOSTDEVICE bool operator==(const Matrix22 &v) const noexcept
Equality.
Definition: ImathMatrix.h:1239
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix22 & scale(const Vec2< S > &s) noexcept
Definition: ImathMatrix.h:305
constexpr ATOMSMATH_HOSTDEVICE Matrix33 operator/(T a) const noexcept
Component-wise division.
Definition: ImathMatrix.h:2195
constexpr ATOMSMATH_HOSTDEVICE bool operator==(const Matrix33 &v) const noexcept
Equality.
Definition: ImathMatrix.h:1890
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & operator-=(const Matrix33 &v) noexcept
Component-wise subtraction.
Definition: ImathMatrix.h:1981
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T minorOf(const int r, const int c) const noexcept
Calculate the matrix minor of the (r,c) element.
Definition: ImathMatrix.h:2690
constexpr ATOMSMATH_HOSTDEVICE T determinant() const noexcept
Determinant.
Definition: ImathMatrix.h:2709
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix33() noexcept
Uninitialized.
Definition: ImathMatrix.h:1680
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeSmallest() noexcept
Smallest possible positive value.
Definition: ImathMatrix.h:592
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & setShear(const S &h) noexcept
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeLowest() noexcept
Largest possible negative value.
Definition: ImathMatrix.h:586
Vec3< T > BaseVecType
The base vector type.
Definition: ImathMatrix.h:606
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & operator/=(T a) noexcept
Component-wise division.
Definition: ImathMatrix.h:2178
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & invert() noexcept
Definition: ImathMatrix.h:2462
constexpr ATOMSMATH_HOSTDEVICE Matrix33 transposed() const noexcept
Return the transpose.
Definition: ImathMatrix.h:2219
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & setScale(T s) noexcept
Definition: ImathMatrix.h:2752
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & translate(const Vec2< S > &t) noexcept
ATOMSMATH_HOSTDEVICE T * operator[](int i) noexcept
Row access.
Definition: ImathMatrix.h:1666
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & scale(const Vec2< S > &s) noexcept
constexpr ATOMSMATH_HOSTDEVICE Matrix33 operator*(T a) const noexcept
Component-wise multiplication.
Definition: ImathMatrix.h:2079
constexpr ATOMSMATH_HOSTDEVICE Vec2< T > translation() const noexcept
Return the translation component.
Definition: ImathMatrix.h:2835
T x[3][3]
Matrix elements.
Definition: ImathMatrix.h:312
ATOMSMATH_HOSTDEVICE const Matrix33 & setRotation(S r) noexcept
ATOMSMATH_HOSTDEVICE void multDirMatrix(const Vec2< S > &src, Vec2< S > &dst) const noexcept
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & negate() noexcept
Component-wise multiplication by -1.
Definition: ImathMatrix.h:2045
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix33< T > inverse() const noexcept
Return the inverse using the determinant, leaving this unmodified.
Definition: ImathMatrix.h:2585
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix33 & setTheMatrix(const Matrix33< S > &v) noexcept
Set the value.
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & operator=(const Matrix33 &v) noexcept
Assignment operator.
Definition: ImathMatrix.h:1774
constexpr ATOMSMATH_HOSTDEVICE bool operator!=(const Matrix33 &v) const noexcept
Inequality.
Definition: ImathMatrix.h:1899
constexpr ATOMSMATH_HOSTDEVICE Matrix33 operator+(const Matrix33 &v) const noexcept
Component-wise addition.
Definition: ImathMatrix.h:1966
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & shear(const S &xy) noexcept
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & transpose() noexcept
Transpose.
Definition: ImathMatrix.h:2210
constexpr ATOMSMATH_HOSTDEVICE T fastMinor(const int r0, const int r1, const int c0, const int c1) const noexcept
Build a minor using the specified rows and columns.
Definition: ImathMatrix.h:2702
ATOMSMATH_HOSTDEVICE const Matrix33 & gjInvert() noexcept
Definition: ImathMatrix.h:2242
ATOMSMATH_HOSTDEVICE void makeIdentity() noexcept
Set to the identity matrix.
Definition: ImathMatrix.h:1875
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeEpsilon() noexcept
Smallest possible e for which 1+e != 1.
Definition: ImathMatrix.h:595
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix33 & setValue(const Matrix33< S > &v) noexcept
Set the value.
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool equalWithAbsError(const Matrix33< T > &v, T e) const noexcept
Definition: ImathMatrix.h:1908
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeMax() noexcept
Largest possible positive value.
Definition: ImathMatrix.h:589
ATOMSMATH_HOSTDEVICE T * getValue() noexcept
Return a raw pointer to the array of values.
Definition: ImathMatrix.h:1811
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & rotate(S r) noexcept
ATOMSMATH_HOSTDEVICE Matrix33< T > gjInverse() const noexcept
Definition: ImathMatrix.h:2356
constexpr static ATOMSMATH_HOSTDEVICE unsigned int dimensions() noexcept
Return the number of the row and column dimensions, i.e. 3.
Definition: ImathMatrix.h:600
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & operator*=(T a) noexcept
Component-wise multiplication.
Definition: ImathMatrix.h:2062
ATOMSMATH_HOSTDEVICE void multVecMatrix(const Vec2< S > &src, Vec2< S > &dst) const noexcept
constexpr ATOMSMATH_HOSTDEVICE Matrix33 operator-() const noexcept
Component-wise multiplication by -1.
Definition: ImathMatrix.h:2030
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & operator+=(const Matrix33 &v) noexcept
Component-wise addition.
Definition: ImathMatrix.h:1932
T BaseType
The base type: In templates that accept a parameter V (could be a Color4), you can refer to T as V::B...
Definition: ImathMatrix.h:603
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix33 & setTranslation(const Vec2< S > &t) noexcept
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool equalWithRelError(const Matrix33< T > &v, T e) const noexcept
Definition: ImathMatrix.h:1920
Definition: ImathMatrix.h:631
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & setAxisAngle(const Vec3< S > &ax, S ang) noexcept
constexpr ATOMSMATH_HOSTDEVICE bool operator==(const Matrix44 &v) const noexcept
Equality.
Definition: ImathMatrix.h:3245
constexpr static ATOMSMATH_HOSTDEVICE unsigned int dimensions() noexcept
Return the number of the row and column dimensions, i.e. 4.
Definition: ImathMatrix.h:975
constexpr ATOMSMATH_HOSTDEVICE Matrix44 operator/(T a) const noexcept
Component-wise division.
Definition: ImathMatrix.h:3662
constexpr ATOMSMATH_HOSTDEVICE Matrix44 transposed() const noexcept
Return the transpose.
Definition: ImathMatrix.h:3708
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & gjInvert() noexcept
Definition: ImathMatrix.h:3738
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeMax() noexcept
Largest possible positive value.
Definition: ImathMatrix.h:964
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeSmallest() noexcept
Smallest possible positive value.
Definition: ImathMatrix.h:967
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & operator+=(const Matrix44 &v) noexcept
Component-wise addition.
Definition: ImathMatrix.h:3293
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44 & setTheMatrix(const Matrix44< S > &v) noexcept
Set the value.
constexpr ATOMSMATH_HOSTDEVICE bool operator!=(const Matrix44 &v) const noexcept
Inequality.
Definition: ImathMatrix.h:3257
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44 & setValue(const Matrix44< S > &v) noexcept
Set the value.
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & operator=(const Matrix44 &v) noexcept
Assignment operator.
Definition: ImathMatrix.h:3092
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool equalWithRelError(const Matrix44< T > &v, T e) const noexcept
Definition: ImathMatrix.h:3281
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & scale(const Vec3< S > &s) noexcept
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & negate() noexcept
Component-wise multiplication by -1.
Definition: ImathMatrix.h:3455
constexpr ATOMSMATH_HOSTDEVICE T fastMinor(const int r0, const int r1, const int r2, const int c0, const int c1, const int c2) const noexcept
Build a minor using the specified rows and columns.
Definition: ImathMatrix.h:4102
ATOMSMATH_HOSTDEVICE void makeIdentity() noexcept
Set to the identity matrix.
Definition: ImathMatrix.h:3223
ATOMSMATH_HOSTDEVICE void multDirMatrix(const Vec3< S > &src, Vec3< S > &dst) const noexcept
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool equalWithAbsError(const Matrix44< T > &v, T e) const noexcept
Definition: ImathMatrix.h:3269
constexpr ATOMSMATH_HOSTDEVICE Matrix44 operator-() const noexcept
Component-wise multiplication by -1.
Definition: ImathMatrix.h:3433
Vec4< T > BaseVecType
The base vector type.
Definition: ImathMatrix.h:981
ATOMSMATH_HOSTDEVICE T * operator[](int i) noexcept
Row access.
Definition: ImathMatrix.h:2934
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeLowest() noexcept
Largest possible negative value.
Definition: ImathMatrix.h:961
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & operator/=(T a) noexcept
Component-wise division.
Definition: ImathMatrix.h:3638
T BaseType
The base type: In templates that accept a parameter V (could be a Color4), you can refer to T as V::B...
Definition: ImathMatrix.h:978
ATOMSMATH_HOSTDEVICE T * getValue() noexcept
Return a raw pointer to the array of values.
Definition: ImathMatrix.h:3138
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeEpsilon() noexcept
Smallest possible e for which 1+e != 1.
Definition: ImathMatrix.h:970
static ATOMSMATH_HOSTDEVICE void multiply(const Matrix44 &a, const Matrix44 &b, Matrix44 &c) noexcept
Matrix-matrix multiplication: compute c = a * b.
Definition: ImathMatrix.h:3554
T x[4][4]
Matrix elements.
Definition: ImathMatrix.h:638
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & setShear(const Vec3< S > &h) noexcept
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & translate(const Vec3< S > &t) noexcept
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & operator*=(T a) noexcept
Component-wise multiplication.
Definition: ImathMatrix.h:3479
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & operator-=(const Matrix44 &v) noexcept
Component-wise subtraction.
Definition: ImathMatrix.h:3363
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & transpose() noexcept
Transpose.
Definition: ImathMatrix.h:3684
ATOMSMATH_HOSTDEVICE const Matrix44 & rotate(const Vec3< S > &r) noexcept
ATOMSMATH_HOSTDEVICE const Matrix44 & setEulerAngles(const Vec3< S > &r) noexcept
constexpr ATOMSMATH_HOSTDEVICE const Vec3< T > translation() const noexcept
Return translation component.
Definition: ImathMatrix.h:4390
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & setScale(T s) noexcept
Definition: ImathMatrix.h:4276
constexpr ATOMSMATH_HOSTDEVICE Matrix44 operator+(const Matrix44 &v) const noexcept
Component-wise addition.
Definition: ImathMatrix.h:3341
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & setTranslation(const Vec3< S > &t) noexcept
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44() noexcept
Uninitialized.
Definition: ImathMatrix.h:2946
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T determinant() const noexcept
Determinant.
Definition: ImathMatrix.h:4140
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44< T > inverse() const noexcept
Return the inverse using the determinant, leaving this unmodified.
Definition: ImathMatrix.h:4036
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & invert() noexcept
Definition: ImathMatrix.h:3958
constexpr ATOMSMATH_HOSTDEVICE Matrix44 operator*(T a) const noexcept
Component-wise multiplication.
Definition: ImathMatrix.h:3503
ATOMSMATH_HOSTDEVICE Matrix44< T > gjInverse() const noexcept
Definition: ImathMatrix.h:3852
ATOMSMATH_HOSTDEVICE void multVecMatrix(const Vec3< S > &src, Vec3< S > &dst) const noexcept
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T minorOf(const int r, const int c) const noexcept
Calculate the matrix minor of the (r,c) element.
Definition: ImathMatrix.h:4116
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44 & shear(const Vec3< S > &h) noexcept
Definition: ImathShear.h:114
Definition: ImathVec.h:43
Definition: ImathVec.h:260
Definition: ImathVec.h:486