PeriDyno 1.0.0
Loading...
Searching...
No Matches
Matrix4x4.h
Go to the documentation of this file.
1#pragma once
2#include <glm/mat4x4.hpp>
3#include "SquareMatrix.h"
4
5namespace dyno {
6
7 template <typename T, int Dim> class Vector;
8
9 /*
10 * SquareMatrix<T,4> are defined for C++ fundamental integer and floating-point types
11 */
12 template <typename T>
13 class SquareMatrix<T, 4>
14 {
15 public:
16 typedef T VarType;
17
18 DYN_FUNC SquareMatrix();
19 DYN_FUNC explicit SquareMatrix(T);
20 DYN_FUNC SquareMatrix(T x00, T x01, T x02, T x03,
21 T x10, T x11, T x12, T x13,
22 T x20, T x21, T x22, T x23,
23 T x30, T x31, T x32, T x33);
24 DYN_FUNC SquareMatrix(const Vector<T, 4> &row1, const Vector<T, 4> &row2, const Vector<T, 4> &row3, const Vector<T, 4> &row4);
25
26 DYN_FUNC SquareMatrix(const SquareMatrix<T, 4>&);
27 DYN_FUNC ~SquareMatrix();
28
29 DYN_FUNC static unsigned int rows() { return 4; }
30 DYN_FUNC static unsigned int cols() { return 4; }
31
32 DYN_FUNC T& operator() (unsigned int i, unsigned int j);
33 DYN_FUNC const T& operator() (unsigned int i, unsigned int j) const;
34
35 DYN_FUNC const Vector<T, 4> row(unsigned int i) const;
36 DYN_FUNC const Vector<T, 4> col(unsigned int i) const;
37
38 DYN_FUNC void setRow(unsigned int i, const Vector<T, 4>& vec);
39 DYN_FUNC void setCol(unsigned int j, const Vector<T, 4>& vec);
40
41 DYN_FUNC const SquareMatrix<T, 4> operator+ (const SquareMatrix<T, 4> &) const;
42 DYN_FUNC SquareMatrix<T, 4>& operator+= (const SquareMatrix<T, 4> &);
43 DYN_FUNC const SquareMatrix<T, 4> operator- (const SquareMatrix<T, 4> &) const;
44 DYN_FUNC SquareMatrix<T, 4>& operator-= (const SquareMatrix<T, 4> &);
45 DYN_FUNC const SquareMatrix<T, 4> operator* (const SquareMatrix<T, 4> &) const;
46 DYN_FUNC SquareMatrix<T, 4>& operator*= (const SquareMatrix<T, 4> &);
47 DYN_FUNC const SquareMatrix<T, 4> operator/ (const SquareMatrix<T, 4> &) const;
48 DYN_FUNC SquareMatrix<T, 4>& operator/= (const SquareMatrix<T, 4> &);
49
50 DYN_FUNC SquareMatrix<T, 4>& operator= (const SquareMatrix<T, 4> &);
51
52 DYN_FUNC bool operator== (const SquareMatrix<T, 4> &) const;
53 DYN_FUNC bool operator!= (const SquareMatrix<T, 4> &) const;
54
55 DYN_FUNC const SquareMatrix<T, 4> operator* (const T&) const;
56 DYN_FUNC SquareMatrix<T, 4>& operator*= (const T&);
57 DYN_FUNC const SquareMatrix<T, 4> operator/ (const T&) const;
58 DYN_FUNC SquareMatrix<T, 4>& operator/= (const T&);
59
60 DYN_FUNC const Vector<T, 4> operator* (const Vector<T, 4> &) const;
61
62 DYN_FUNC const SquareMatrix<T, 4> operator- (void) const;
63
64 DYN_FUNC const SquareMatrix<T, 4> transpose() const;
65 DYN_FUNC const SquareMatrix<T, 4> inverse() const;
66
67 DYN_FUNC T determinant() const;
68 DYN_FUNC T trace() const;
69 DYN_FUNC T doubleContraction(const SquareMatrix<T, 4> &) const;//double contraction
70 DYN_FUNC T frobeniusNorm() const;
71 DYN_FUNC T oneNorm() const;
72 DYN_FUNC T infNorm() const;
73
74 DYN_FUNC static const SquareMatrix<T, 4> identityMatrix();
75
76 DYN_FUNC T* getDataPtr() { return &data_[0].x; }
77
78 protected:
79 glm::tmat4x4<T> data_; //default: zero matrix
80 };
81
82 template class SquareMatrix<float, 4>;
83 template class SquareMatrix<double, 4>;
84 //convenient typedefs
87
88} //end of namespace dyno
89
90#include "Matrix4x4.inl"
static DYN_FUNC unsigned int cols()
Definition Matrix4x4.h:30
DYN_FUNC T * getDataPtr()
Definition Matrix4x4.h:76
glm::tmat4x4< T > data_
Definition Matrix4x4.h:79
static DYN_FUNC unsigned int rows()
Definition Matrix4x4.h:29
#define T(t)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
SquareMatrix< double, 4 > Mat4d
Definition Matrix4x4.h:86
DYN_FUNC const Complex< T > operator/(S scale, const Complex< T > &complex)
Definition Complex.inl:253
DYN_FUNC const Complex< T > operator*(S scale, const Complex< T > &complex)
Definition Complex.inl:247
DYN_FUNC bool operator==(const priority_queue< T, Container, Compare > &a, const priority_queue< T, Container, Compare > &b)
DYN_FUNC bool operator!=(const priority_queue< T, Container, Compare > &a, const priority_queue< T, Container, Compare > &b)
DYN_FUNC const Complex< T > operator-(S scale, const Complex< T > &complex)
Definition Complex.inl:241
DYN_FUNC const Complex< T > operator+(S scale, const Complex< T > &complex)
Definition Complex.inl:235
SquareMatrix< float, 4 > Mat4f
Definition Matrix4x4.h:85