31 static constexpr Matrix2 scale( T sx, T sy )
noexcept {
return Matrix2( { sx, T(0) }, { T(0), sy } ); }
51 constexpr T
trace() const noexcept {
return x.x +
y.y; }
53 constexpr T
normSq() const noexcept {
return x.lengthSq() +
y.lengthSq(); }
54 constexpr auto norm() const noexcept
62 constexpr T
det() const noexcept;
73 if constexpr ( std::is_integral_v<T> )
74 {
x /= b;
y /= b;
return *
this; }
76 return *
this *= ( 1 / b );
87 return { dot( a.
x, b ), dot( a.
y, b ) };
94 return dot( a.
x, b.
x ) + dot( a.
y, b.
y );
102 for (
int i = 0; i < 2; ++i )
103 for (
int j = 0; j < 2; ++j )
104 res[i][j] = dot( a[i], b.
col(j) );
112 return { a.
x * b, a.
y * b };
117 {
return a.
x == b.
x && a.
y == b.
y; }
121 {
return !( a == b ); }
125 {
return { a.x + b.x, a.y + b.y }; }
129 {
return { a.x - b.x, a.y - b.y }; }
133 {
return { a * b.x, a * b.y }; }
137 {
return { a * b.x, a * b.y }; }
141 { b /= a;
return b; }
157 const auto x = cross( from, to );
159 return rotation(
angle( from, to ) );
161 return rotation( -
angle( from, to ) );
162 if (
dot( from, to ) >= 0 )
164 return rotation( T( PI ) );
170 return x.x * y.y - x.y * y.x;
176 auto det = this->det();
#define MR_REQUIRES_IF_SUPPORTED(...)
Definition MRMacros.h:29
BitSet operator-(const BitSet &a, const BitSet &b)
Definition MRMesh/MRBitSet.h:342
MRMESH_API bool operator==(const BitSet &a, const BitSet &b)
compare that two bit sets have the same set bits (they can be equal even if sizes are distinct but la...
bool operator!=(const SetBitIteratorT< T > &a, const SetBitIteratorT< T > &b)
Definition MRMesh/MRBitSet.h:276
constexpr auto dot(A a, A b)
Definition MRImGuiVectorOperators.h:129
Definition MRCameraOrientationPlugin.h:8
MRMESH_CLASS Vector3< double > Matrix2
Definition MRMesh/MRMeshFwd.h:153
Color operator/(const Color &b, float a)
Definition MRColor.h:128
Color operator*(float a, const Color &b)
Definition MRColor.h:118
Color operator+(const Color &a, const Color &b)
Definition MRColor.h:108
Definition MRMatrix2.h:13
constexpr Matrix2(const Matrix2< U > &m)
Definition MRMatrix2.h:25
Vector2< T > x
rows, identity matrix by default
Definition MRMatrix2.h:18
static constexpr Matrix2 scale(T s) noexcept
returns a matrix that scales uniformly
Definition MRMatrix2.h:29
constexpr T normSq() const noexcept
compute sum of squared matrix elements
Definition MRMatrix2.h:53
Matrix2< T > outer(const Vector2< T > &a, const Vector2< T > &b)
x = a * b^T
Definition MRMatrix2.h:110
static constexpr Matrix2 static rotation(T angle) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix2 static rotation(const Vector2< T > &from, const Vector2< T > &to) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix fromRows)(const Vector2< T > &x, const Vector2< T > &y) noexcept
creates matrix representing rotation around origin on given angle
Definition MRMatrix2.h:38
constexpr Vector2< T > col(int i) const noexcept
column access
Definition MRMatrix2.h:48
static constexpr Matrix2 identity() noexcept
Definition MRMatrix2.h:27
Vector2< T > y
Definition MRMatrix2.h:19
T ValueType
Definition MRMatrix2.h:14
constexpr T det() const noexcept
computes determinant of the matrix
static constexpr Matrix2 scale(const Vector2< T > &s) noexcept
Definition MRMatrix2.h:32
static constexpr Matrix2 scale(T sx, T sy) noexcept
returns a matrix that has its own scale along each axis
Definition MRMatrix2.h:31
constexpr T trace() const noexcept
computes trace of the matrix
Definition MRMatrix2.h:51
constexpr const Vector2< T > & operator[](int row) const noexcept
row access
Definition MRMatrix2.h:44
Matrix2 & operator*=(T b)
Definition MRMatrix2.h:70
constexpr Matrix2() noexcept=default
T dot(const Matrix2< T > &a, const Matrix2< T > &b)
double-dot product: x = a : b
Definition MRMatrix2.h:92
Matrix2 & operator-=(const Matrix2< T > &b)
Definition MRMatrix2.h:69
constexpr Matrix2< T > inverse() const noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix2< T > transposed() const noexcept
computes inverse matrix
constexpr auto norm() const noexcept
Definition MRMatrix2.h:54
static constexpr Matrix2 zero() noexcept
Definition MRMatrix2.h:26
Matrix2 & operator/=(T b)
Definition MRMatrix2.h:71
static constexpr Matrix2 fromColumns(const Vector2< T > &x, const Vector2< T > &y) noexcept
Definition MRMatrix2.h:41
Definition MRVector2.h:18
T x
Definition MRVector2.h:24
T y
Definition MRVector2.h:24