12#define __MATRIX3_H__ 1
14#include "math/vector_2.h"
15#include "math/vector_3.h"
21 Mat3(
float* values_array);
78 inline Mat3 operator+(
const Mat3& other)
const;
79 inline Mat3& operator+=(
const Mat3& other);
80 inline Mat3 operator+(
float value)
const;
81 inline Mat3& operator+=(
float value);
82 inline Mat3 operator-(
const Mat3& other)
const;
83 inline Mat3& operator-=(
const Mat3& other);
84 inline Mat3 operator-(
float value)
const;
85 inline Mat3& operator-=(
float value);
86 inline Mat3 operator*(
float value)
const;
87 inline Mat3& operator*=(
float value);
88 inline Mat3 operator/(
float value)
const;
89 inline Mat3& operator/=(
float value);
90 bool operator==(
const Mat3& other)
const;
91 bool operator!=(
const Mat3& other)
const;
92 inline void operator=(
const Mat3& other);
97inline Mat3 Mat3::operator+(
const Mat3& other)
const {
99 for (
int i = 0; i < 9; i++) {
100 res.m[i] = m[i] + other.m[i];
105inline Mat3& Mat3::operator+=(
const Mat3& other) {
106 for (
int i = 0; i < 9; i++) {
112inline Mat3 Mat3::operator+(
float value)
const {
114 for (
int i = 0; i < 9; i++) {
115 res.m[i] = m[i] + value;
120inline Mat3& Mat3::operator+=(
float value) {
121 for (
int i = 0; i < 9; i++) {
127inline Mat3 Mat3::operator-(
const Mat3& other)
const {
129 for (
int i = 0; i < 9; i++) {
130 res.m[i] = m[i] - other.m[i];
135inline Mat3& Mat3::operator-=(
const Mat3& other) {
136 for (
int i = 0; i < 9; i++) {
142inline Mat3 Mat3::operator-(
float value)
const {
144 for (
int i = 0; i < 9; i++) {
145 res.m[i] = m[i] - value;
150inline Mat3& Mat3::operator-=(
float value) {
151 for (
int i = 0; i < 9; i++) {
157inline Mat3 Mat3::operator*(
float value)
const {
159 for (
int i = 0; i < 9; i++) {
160 res.m[i] = m[i] * value;
165inline Mat3& Mat3::operator*=(
float value) {
166 for (
int i = 0; i < 9; i++) {
172inline Mat3 Mat3::operator/(
float value)
const {
174 for (
int i = 0; i < 9; i++) {
175 res.m[i] = m[i] / value;
180inline Mat3& Mat3::operator/=(
float value) {
181 for (
int i = 0; i < 9; i++) {
187inline bool Mat3::operator==(
const Mat3& other)
const {
188 for (
int i = 0; i < 9; i++) {
189 if (m[i] != other.m[i])
return false;
194inline bool Mat3::operator!=(
const Mat3& other)
const {
195 for (
int i = 0; i < 9; i++) {
196 if (m[i] != other.m[i])
return true;
201inline void Mat3::operator=(
const Mat3& other) {
202 for (
int i = 0; i < 9; i++) {
212 return (m[0] * m[4] * m[8]) + (m[1] * m[5] * m[6]) + (m[2] * m[3] * m[7]) -
213 (m[2] * m[4] * m[6]) - (m[1] * m[3] * m[8]) - (m[0] * m[5] * m[7]);
218 if (det == 0)
return false;
225 if (det == 0)
return false;
232 res.m[2] = mov_vector.x;
233 res.m[5] = mov_vector.y;
246 for (
int row = 0; row < 3; row++) {
247 for (
int col = 0; col < 3; col++) {
248 res.m[row * 3 + col] = m[row * 3 + 0] * other.m[0 * 3 + col] +
249 m[row * 3 + 1] * other.m[1 * 3 + col] +
250 m[row * 3 + 2] * other.m[2 * 3 + col];
257 return Mat3(
Vec3(m[4] * m[8] - m[5] * m[7], -(m[3] * m[8] - m[5] * m[6]),
258 m[3] * m[7] - m[4] * m[6]),
259 Vec3(-(m[1] * m[8] - m[2] * m[7]), m[0] * m[8] - m[2] * m[6],
260 -(m[0] * m[7] - m[1] * m[6])),
261 Vec3(m[1] * m[5] - m[2] * m[4], -(m[0] * m[5] - m[2] * m[3]),
262 m[0] * m[4] - m[1] * m[3]));
266 return Mat3(
Vec3(m[0], m[3], m[6]),
Vec3(m[1], m[4], m[7]),
267 Vec3(m[2], m[5], m[8]));
271 return Vec3(m[colum], m[3 + colum], m[6 + colum]);
275 return Vec3(m[line * 3 + 0], m[line * 3 + 1], m[line * 3 + 2]);
represents mathematical matrix with 3 cols and 3 rows
Definition: matrix_3.h:18
Mat3 Transpose() const
Definition: matrix_3.h:265
Mat3 Adjoint() const
Definition: matrix_3.h:256
Mat3 Multiply(const Mat3 &other) const
Definition: matrix_3.h:244
float Determinant() const
Definition: matrix_3.h:211
Vec3 GetLine(int line) const
Definition: matrix_3.h:274
static Mat3 Identity()
Definition: matrix_3.h:207
bool Inverse()
Definition: matrix_3.h:223
static Mat3 Translate(const Vec2 &position)
Definition: matrix_3.h:230
Vec3 GetColum(int colum) const
Definition: matrix_3.h:270
bool GetInverse(Mat3 &out) const
Definition: matrix_3.h:216
represents mathematical vector with 2 components
Definition: vector_2.h:7
represents mathematical vector with 3 components
Definition: vector_3.h:12
copperdielf Math Library
Definition: buffer.hpp:5