|
Implementation of a 3D symmetric matrix. More...
#include <MatrixSymmetric.h>
Public Member Functions | |
operator Matrix3D () const | |
Casting operator; casts MatrixSymmetric3D to Matrix3D. More... | |
MatrixSymmetric3D () | |
Default constructor. More... | |
MatrixSymmetric3D (Mdouble xx, Mdouble xy, Mdouble xz, Mdouble yy, Mdouble yz, Mdouble zz) | |
Alternative constructor, with all (6) elements as arguments. More... | |
void | setZero () |
Sets all elements to zero. More... | |
Mdouble | trace () const |
Returns the MEAN of the diagonal elements (i.e. the trace divided by three). More... | |
MatrixSymmetric3D | operator+ (const MatrixSymmetric3D &A) const |
Matrix addition. More... | |
MatrixSymmetric3D | operator- (const MatrixSymmetric3D &A) const |
Matrix substraction. More... | |
MatrixSymmetric3D | operator+ (Mdouble a) const |
Scalar addition. More... | |
MatrixSymmetric3D | operator- (Mdouble a) const |
Scalar substraction. More... | |
MatrixSymmetric3D | operator* (Mdouble a) const |
Scalar multiplication. More... | |
MatrixSymmetric3D | operator/ (Mdouble a) const |
Scalar division. More... | |
MatrixSymmetric3D & | operator+= (const MatrixSymmetric3D &A) |
Matrix addition. More... | |
MatrixSymmetric3D & | operator-= (const MatrixSymmetric3D &A) |
Matrix substraction. More... | |
MatrixSymmetric3D & | operator/= (Mdouble a) |
Scalar division. More... | |
MatrixSymmetric3D | inverse () const |
Computes the inverse of a matrix; exits if the inverse doesn't exist. More... | |
MatrixSymmetric3D | getCylindricalTensorField (const Vec3D &p) const |
Returns the matrix in cylindrical coordinates. More... | |
Static Public Member Functions | |
static MatrixSymmetric3D | square (const MatrixSymmetric3D &A) |
Calculates the pointwise square. More... | |
static MatrixSymmetric3D | sqrt (const MatrixSymmetric3D &A) |
Calculates the pointwise square root. More... | |
static MatrixSymmetric3D | selfDyadic (const Vec3D &a) |
Calculates the dyadic product of a Vec3D with itself: \(a \otimes a\). More... | |
static MatrixSymmetric3D | symmetrisedDyadic (const Vec3D &a, const Vec3D &b) |
Calculates the symmetrised dyadic product of two Vec3D: \( \frac{1}{2}(a \otimes b + b \otimes a) \). More... | |
static MatrixSymmetric3D | inverse (const MatrixSymmetric3D &A) |
Computes the inverse of a matrix; exits if the inverse doesn't exist. More... | |
static Mdouble | determinant (const MatrixSymmetric3D &A) |
Computes the determinant of a matrix. More... | |
Public Attributes | |
Mdouble | XX |
The six distinctive matrix elements. More... | |
Mdouble | XY |
Mdouble | XZ |
Mdouble | YY |
Mdouble | YZ |
Mdouble | ZZ |
Friends | |
Vec3D | operator* (const MatrixSymmetric3D &A, const Vec3D &b) |
Vector multiplication. More... | |
std::ostream & | operator<< (std::ostream &os, const MatrixSymmetric3D &A) |
Add elements to an ostream. More... | |
std::istream & | operator>> (std::istream &is, MatrixSymmetric3D &A) |
Add elements to an istream. More... | |
Implementation of a 3D symmetric matrix.
MatrixSymmetric3D::MatrixSymmetric3D | ( | ) |
Default constructor.
Default constructor
References setZero().
Referenced by operator*(), operator+(), operator-(), operator/(), selfDyadic(), sqrt(), square(), and symmetrisedDyadic().
MatrixSymmetric3D::MatrixSymmetric3D | ( | Mdouble | xx, |
Mdouble | xy, | ||
Mdouble | xz, | ||
Mdouble | yy, | ||
Mdouble | yz, | ||
Mdouble | zz | ||
) |
Alternative constructor, with all (6) elements as arguments.
Alternative constructor, lets you define all (6) elements
[in] | xx | initializer for an element of the matrix |
[in] | xy | initializer for an element of the matrix |
[in] | xz | initializer for an element of the matrix |
[in] | yy | initializer for an element of the matrix |
[in] | yz | initializer for an element of the matrix |
[in] | zz | initializer for an element of the matrix |
|
static |
MatrixSymmetric3D MatrixSymmetric3D::getCylindricalTensorField | ( | const Vec3D & | p | ) | const |
Returns the matrix in cylindrical coordinates.
Transforms the (Cartesian) vector to cylindrical coordinates. See https://en.wikipedia.org/wiki/Vector_fields_in_cylindrical_and_spherical_coordinates
Referenced by CGFields::StandardFields::setCylindricalFields().
MatrixSymmetric3D MatrixSymmetric3D::inverse | ( | ) | const |
Computes the inverse of a matrix; exits if the inverse doesn't exist.
Used for inverting matrices like the inertia tensor.
[in] | A | Matrix that should be inverted. |
References determinant(), logger, XX, XY, XZ, YY, YZ, and ZZ.
Referenced by BaseParticle::setInertia().
|
static |
Computes the inverse of a matrix; exits if the inverse doesn't exist.
Used for inverting matrices like the inertia tensor.
[in] | A | Matrix that should be inverted. |
References A.
Referenced by ClumpParticle::ClumpParticle(), ClumpParticle::computeMass(), BaseParticle::getAngularMomentum(), BaseParticle::getInertia(), ClumpParticle::rotateTensorOfInertia(), and ClumpParticle::setInitInertia().
|
explicit |
MatrixSymmetric3D MatrixSymmetric3D::operator* | ( | Mdouble | a | ) | const |
Scalar multiplication.
Scalar multiplication
[in] | a | the scalar |
MatrixSymmetric3D MatrixSymmetric3D::operator+ | ( | const MatrixSymmetric3D & | A | ) | const |
MatrixSymmetric3D MatrixSymmetric3D::operator+ | ( | Mdouble | a | ) | const |
MatrixSymmetric3D & MatrixSymmetric3D::operator+= | ( | const MatrixSymmetric3D & | A | ) |
Matrix addition.
Matrix addition
[in] | A | the matrix to be added to this one |
MatrixSymmetric3D MatrixSymmetric3D::operator- | ( | const MatrixSymmetric3D & | A | ) | const |
MatrixSymmetric3D MatrixSymmetric3D::operator- | ( | Mdouble | a | ) | const |
MatrixSymmetric3D & MatrixSymmetric3D::operator-= | ( | const MatrixSymmetric3D & | A | ) |
Matrix substraction.
Matrix substraction
[in] | A | the matrix to be subtracted |
MatrixSymmetric3D MatrixSymmetric3D::operator/ | ( | Mdouble | a | ) | const |
MatrixSymmetric3D & MatrixSymmetric3D::operator/= | ( | Mdouble | a | ) |
|
static |
Calculates the dyadic product of a Vec3D with itself: \(a \otimes a\).
Calculates the dyadic product of a 3D vector with itself, which (obviously) results in a symmetric 3D matrix. NB: this is a STATIC function!
[in] | a | the 3D vector |
References MatrixSymmetric3D(), Vec3D::X, Vec3D::Y, and Vec3D::Z.
Referenced by CGFields::StandardFields::setFields().
void MatrixSymmetric3D::setZero | ( | ) |
Sets all elements to zero.
Sets all elements of the symmetric matrix to 0.
References XX, XY, XZ, YY, YZ, and ZZ.
Referenced by MatrixSymmetric3D(), BaseParticle::setInfiniteInertia(), CGFields::OrientationField::setZero(), and CGFields::StandardFields::setZero().
|
static |
Calculates the pointwise square root.
Pointwise square roots the matrix, i.e. takes the sq. root of each element. NB: this is a STATIC function!
[in] | A | The matrix to be pointwise square rooted |
References A, and MatrixSymmetric3D().
|
static |
Calculates the pointwise square.
Pointwise squares the matrix, i.e. takes the square of each element. NB: is a STATIC function!
[in] | A | The matrix to be pointwise squared |
References A, MatrixSymmetric3D(), and mathsFunc::square().
Referenced by CGFields::OrientationField::getSquared(), and CGFields::StandardFields::getSquared().
|
static |
Calculates the symmetrised dyadic product of two Vec3D: \( \frac{1}{2}(a \otimes b + b \otimes a) \).
Calculates the dyadic product of two 3D vectors, and 'symmetrises' the resulting matrix by taking the average of each pair of opposing non-diagonal elements. NB: this is a STATIC function!
[in] | a | the first 3D vector |
[in] | b | the second 3D vector |
References MatrixSymmetric3D(), Vec3D::X, Vec3D::Y, and Vec3D::Z.
Mdouble MatrixSymmetric3D::trace | ( | ) | const |
Returns the MEAN of the diagonal elements (i.e. the trace divided by three).
Returns the MEAN of the diagonal matrix elements, which is technically the trace divided by the number of diagonal elements.
|
friend |
Vector multiplication.
Multiplication of a symmetric 3D matrix with a vector (global operator, friend of this class)
[in] | A | the matrix |
[in] | b | the vector |
|
friend |
Add elements to an ostream.
Adds all elements of a symmetric 3D matrix to an ostream
[in,out] | os | output stream |
[in] | A | the matrix |
|
friend |
Mdouble MatrixSymmetric3D::XX |
The six distinctive matrix elements.
Referenced by ClumpParticle::angularAccelerateClumpIterative(), SuperQuadricParticle::computeMass(), inverse(), mathsFunc::isEqual(), MatrixSymmetric3D(), BaseParticle::oldRead(), operator*(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), Quaternion::rotateInverseInertiaTensor(), CGFields::OrientationField::setFields(), SuperQuadricParticle::setInertia(), setZero(), InertiaTensorTester::test(), and trace().
Mdouble MatrixSymmetric3D::XY |
Referenced by ClumpParticle::angularAccelerateClumpIterative(), SuperQuadricParticle::computeMass(), inverse(), mathsFunc::isEqual(), MatrixSymmetric3D(), operator*(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), Quaternion::rotateInverseInertiaTensor(), CGFields::OrientationField::setFields(), and setZero().
Mdouble MatrixSymmetric3D::XZ |
Referenced by ClumpParticle::angularAccelerateClumpIterative(), SuperQuadricParticle::computeMass(), inverse(), mathsFunc::isEqual(), MatrixSymmetric3D(), operator*(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), Quaternion::rotateInverseInertiaTensor(), CGFields::OrientationField::setFields(), and setZero().
Mdouble MatrixSymmetric3D::YY |
Referenced by ClumpParticle::angularAccelerateClumpIterative(), SuperQuadricParticle::computeMass(), inverse(), mathsFunc::isEqual(), MatrixSymmetric3D(), BaseParticle::oldRead(), operator*(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), Quaternion::rotateInverseInertiaTensor(), CGFields::OrientationField::setFields(), SuperQuadricParticle::setInertia(), setZero(), InertiaTensorTester::test(), and trace().
Mdouble MatrixSymmetric3D::YZ |
Referenced by ClumpParticle::angularAccelerateClumpIterative(), SuperQuadricParticle::computeMass(), inverse(), mathsFunc::isEqual(), MatrixSymmetric3D(), operator*(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), Quaternion::rotateInverseInertiaTensor(), CGFields::OrientationField::setFields(), and setZero().
Mdouble MatrixSymmetric3D::ZZ |
Referenced by ClumpParticle::angularAccelerateClumpIterative(), SuperQuadricParticle::computeMass(), inverse(), mathsFunc::isEqual(), MatrixSymmetric3D(), BaseParticle::oldRead(), operator*(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), Quaternion::rotateInverseInertiaTensor(), CGFields::OrientationField::setFields(), SuperQuadricParticle::setInertia(), setZero(), InertiaTensorTester::test(), and trace().