CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
matr3d.h File Reference

MATRIX_3x3 class and functions. More...

#include "vector3d.h"

Go to the source code of this file.

Classes

class  MATRIX_3x3
 MATRIX_3x3 class and functions. More...
 

Functions

MATRIX_3x3 operator* (const MATRIX_3x3 &A, const MATRIX_3x3 &B)
 Arithmetic operator - multiplication of 2 matrices.
 
MATRIX_3x3 operator& (const MATRIX_3x3 &A, const MATRIX_3x3 &B)
 Arithmetic operator - multiplication of 2 matrices components ( AxxBxx, AxyBxy, ..., AzzBzz )
 
MATRIX_3x3 operator! (const MATRIX_3x3 &A)
 Arithmetic operator - matrix transposition ( A^T )
 
MATRIX_3x3 operator~ (const MATRIX_3x3 &A)
 Arithmetic operator - matrix inversion ( A^(-1) )
 
MATRIX_3x3 operator* (const MATRIX_3x3 &A, const double &s)
 Arithmetic operator - product of matrix and scalar.
 
MATRIX_3x3 operator* (const double &s, const MATRIX_3x3 &A)
 Arithmetic operator - product of scalar and matrix.
 
MATRIX_3x3 operator/ (const MATRIX_3x3 &A, const double &s)
 Arithmetic operator - division of matrix by scalar (product of matrix and 1/s)
 
MATRIX_3x3 operator+ (const MATRIX_3x3 &A, const MATRIX_3x3 &B)
 Arithmetic operator - sum of 2 matrices.
 
MATRIX_3x3 operator- (const MATRIX_3x3 &A, const MATRIX_3x3 &B)
 Arithmetic operator - subtraction of 2 matrices (sum of A and -B)
 
MATRIX_3x3 operator- (const MATRIX_3x3 &A)
 Arithmetic operator - reverse of matrix (-A)
 
void operator/= (MATRIX_3x3 &A, const double &s)
 Arithmetic operator - division assignment.
 
VECTOR_3D operator* (const MATRIX_3x3 &A, const VECTOR_3D &b)
 Arithmetic operator - multiplication of matrix and vector.
 
VECTOR_3D operator* (const VECTOR_3D &b, const MATRIX_3x3 &A)
 Arithmetic operator - multiplication of vector and matrix.
 
VECTOR_3D operator/ (const VECTOR_3D &b, MATRIX_3x3 &A)
 Arithmetic operator - multiplication of vector and inverted matrix.
 
void v_printf (char *name, const MATRIX_3x3 &mat)
 print to stdout name and matrix components
 
void v_printf (char *fmt, char *name, const MATRIX_3x3 &mat)
 print to stdout name and matrix components according to given format "fmt"
 
void v_sprintf (char *dest, char *name, const MATRIX_3x3 &mat)
 print to string "dest" name and matrix components
 
void v_sprintf (char *dest, char *fmt, char *name, const MATRIX_3x3 &mat)
 print to string "dest" name and matrix components according to given format "fmt"
 
void v_fprintf (FILE *dest, char *name, const MATRIX_3x3 &mat)
 print to stream "dest" name and matrix components
 
void v_fprintf (FILE *dest, char *fmt, char *name, const MATRIX_3x3 &mat)
 print to sstream "dest" name and matrix components according to given format "fmt"
 
std::ostream & operator<< (std::ostream &out, const MATRIX_3x3 &mat)
 print to std:ostream
 

Detailed Description

MATRIX_3x3 class and functions.

Definition in file matr3d.h.

Function Documentation

◆ operator!()

MATRIX_3x3 operator! ( const MATRIX_3x3 & A)

Arithmetic operator - matrix transposition ( A^T )

Definition at line 142 of file matr3d.cpp.

143{
144 return MATRIX_3x3 (
145 A.xx , A.yx , A.zx ,
146 A.xy , A.yy , A.zy ,
147 A.xz , A.yz , A.zz
148 );
149}
MATRIX_3x3 class and functions.
Definition matr3d.h:41
double yy
(1,1) element
Definition matr3d.h:48
double xx
(0,0) element
Definition matr3d.h:44
double zz
(2,2) element
Definition matr3d.h:52
double yz
(1,2) element
Definition matr3d.h:49
double zx
(2,0) element
Definition matr3d.h:50
double yx
(1,0) element
Definition matr3d.h:47
double xz
(0,2) element
Definition matr3d.h:46
double xy
(0,1) element
Definition matr3d.h:45
double zy
(2,1) element
Definition matr3d.h:51

◆ operator&()

MATRIX_3x3 operator& ( const MATRIX_3x3 & A,
const MATRIX_3x3 & B )

Arithmetic operator - multiplication of 2 matrices components ( AxxBxx, AxyBxy, ..., AzzBzz )

Definition at line 51 of file matr3d.cpp.

52{
53 MATRIX_3x3 C;
54
55 C.xx = A.xx * B.xx; C.xy = A.xy * B.xy; C.xz = A.xz * B.xz;
56 C.yx = A.yx * B.yx; C.yy = A.yy * B.yy; C.yz = A.yz * B.yz;
57 C.zx = A.zx * B.zx; C.zy = A.zy * B.zy; C.zz = A.zz * B.zz;
58
59 return C;
60}

◆ operator*() [1/5]

MATRIX_3x3 operator* ( const double & s,
const MATRIX_3x3 & A )

Arithmetic operator - product of scalar and matrix.

Definition at line 112 of file matr3d.cpp.

113{
114 MATRIX_3x3 C;
115
116 C.xx = A.xx * s; C.xy = A.xy * s; C.xz = A.xz * s;
117 C.yx = A.yx * s; C.yy = A.yy * s; C.yz = A.yz * s;
118 C.zx = A.zx * s; C.zy = A.zy * s; C.zz = A.zz * s;
119
120 return C;
121}

◆ operator*() [2/5]

MATRIX_3x3 operator* ( const MATRIX_3x3 & A,
const double & s )

Arithmetic operator - product of matrix and scalar.

Definition at line 100 of file matr3d.cpp.

101{
102 MATRIX_3x3 C;
103
104 C.xx = A.xx * s; C.xy = A.xy * s; C.xz = A.xz * s;
105 C.yx = A.yx * s; C.yy = A.yy * s; C.yz = A.yz * s;
106 C.zx = A.zx * s; C.zy = A.zy * s; C.zz = A.zz * s;
107
108 return C;
109}

◆ operator*() [3/5]

MATRIX_3x3 operator* ( const MATRIX_3x3 & A,
const MATRIX_3x3 & B )

Arithmetic operator - multiplication of 2 matrices.

Definition at line 152 of file matr3d.cpp.

153{
154 MATRIX_3x3 C;
155
156 C.xx = A.xx * B.xx + A.xy * B.yx + A.xz * B.zx;
157 C.yx = A.yx * B.xx + A.yy * B.yx + A.yz * B.zx;
158 C.zx = A.zx * B.xx + A.zy * B.yx + A.zz * B.zx;
159
160 C.xy = A.xx * B.xy + A.xy * B.yy + A.xz * B.zy;
161 C.yy = A.yx * B.xy + A.yy * B.yy + A.yz * B.zy;
162 C.zy = A.zx * B.xy + A.zy * B.yy + A.zz * B.zy;
163
164 C.xz = A.xx * B.xz + A.xy * B.yz + A.xz * B.zz;
165 C.yz = A.yx * B.xz + A.yy * B.yz + A.yz * B.zz;
166 C.zz = A.zx * B.xz + A.zy * B.yz + A.zz * B.zz;
167
168 return C;
169}

◆ operator*() [4/5]

VECTOR_3D operator* ( const MATRIX_3x3 & A,
const VECTOR_3D & b )

Arithmetic operator - multiplication of matrix and vector.

Definition at line 27 of file matr3d.cpp.

28{
29 VECTOR_3D w;
30
31 w.x = A.xx * b.x + A.xy * b.y + A.xz * b.z;
32 w.y = A.yx * b.x + A.yy * b.y + A.yz * b.z;
33 w.z = A.zx * b.x + A.zy * b.y + A.zz * b.z;
34
35 return w;
36}
Vector 3D class - vector manipulation.
Definition vector3d.h:34
double x
x coordinate
Definition vector3d.h:38
double z
z coordinate
Definition vector3d.h:38
double y
y coordinate
Definition vector3d.h:38

◆ operator*() [5/5]

VECTOR_3D operator* ( const VECTOR_3D & b,
const MATRIX_3x3 & A )

Arithmetic operator - multiplication of vector and matrix.

Definition at line 39 of file matr3d.cpp.

40{
41 VECTOR_3D w;
42
43 w.x = b.x * A.xx + b.y * A.yx + b.z * A.zx;
44 w.y = b.x * A.xy + b.y * A.yy + b.z * A.zy;
45 w.z = b.x * A.xz + b.y * A.yz + b.z * A.zz;
46
47 return w;
48}

◆ operator+()

MATRIX_3x3 operator+ ( const MATRIX_3x3 & A,
const MATRIX_3x3 & B )

Arithmetic operator - sum of 2 matrices.

Definition at line 63 of file matr3d.cpp.

64{
65 MATRIX_3x3 C;
66
67 C.xx = A.xx + B.xx; C.xy = A.xy + B.xy; C.xz = A.xz + B.xz;
68 C.yx = A.yx + B.yx; C.yy = A.yy + B.yy; C.yz = A.yz + B.yz;
69 C.zx = A.zx + B.zx; C.zy = A.zy + B.zy; C.zz = A.zz + B.zz;
70
71 return C;
72}

◆ operator-() [1/2]

MATRIX_3x3 operator- ( const MATRIX_3x3 & A)

Arithmetic operator - reverse of matrix (-A)

Definition at line 87 of file matr3d.cpp.

88{
89 MATRIX_3x3 C;
90
91 C.xx = -A.xx; C.xy = -A.xy; C.xz = -A.xz;
92 C.yx = -A.yx; C.yy = -A.yy; C.yz = -A.yz;
93 C.zx = -A.zx; C.zy = -A.zy; C.zz = -A.zz;
94
95 return C;
96}

◆ operator-() [2/2]

MATRIX_3x3 operator- ( const MATRIX_3x3 & A,
const MATRIX_3x3 & B )

Arithmetic operator - subtraction of 2 matrices (sum of A and -B)

Definition at line 75 of file matr3d.cpp.

76{
77 MATRIX_3x3 C;
78
79 C.xx = A.xx - B.xx; C.xy = A.xy - B.xy; C.xz = A.xz - B.xz;
80 C.yx = A.yx - B.yx; C.yy = A.yy - B.yy; C.yz = A.yz - B.yz;
81 C.zx = A.zx - B.zx; C.zy = A.zy - B.zy; C.zz = A.zz - B.zz;
82
83 return C;
84}

◆ operator/() [1/2]

MATRIX_3x3 operator/ ( const MATRIX_3x3 & A,
const double & s )

Arithmetic operator - division of matrix by scalar (product of matrix and 1/s)

Definition at line 124 of file matr3d.cpp.

125{
126 MATRIX_3x3 C;
127
128 C.xx = A.xx / s; C.xy = A.xy / s; C.xz = A.xz / s;
129 C.yx = A.yx / s; C.yy = A.yy / s; C.yz = A.yz / s;
130 C.zx = A.zx / s; C.zy = A.zy / s; C.zz = A.zz / s;
131
132 return C;
133}

◆ operator/() [2/2]

VECTOR_3D operator/ ( const VECTOR_3D & b,
MATRIX_3x3 & A )

Arithmetic operator - multiplication of vector and inverted matrix.

Definition at line 196 of file matr3d.cpp.

197{
198 return b * ~B;
199}

◆ operator/=()

void operator/= ( MATRIX_3x3 & A,
const double & s )

Arithmetic operator - division assignment.

Definition at line 135 of file matr3d.cpp.

136{
137 A.xx /= s; A.xy /= s; A.xz /= s;
138 A.yx /= s; A.yy /= s; A.yz /= s;
139 A.zx /= s; A.zy /= s; A.zz /= s;
140}

◆ operator~()

MATRIX_3x3 operator~ ( const MATRIX_3x3 & A)

Arithmetic operator - matrix inversion ( A^(-1) )

Definition at line 171 of file matr3d.cpp.

172{
173// C = A^(-1)
174
175 MATRIX_3x3 C = A;
176 double w = C.Det();
177 C.SetToZero();
178
179 C.xx = A.yy * A.zz - A.zy * A.yz;
180 C.xy = A.xz * A.zy - A.xy * A.zz;
181 C.xz = A.xy * A.yz - A.xz * A.yy;
182
183 C.yx = A.yz * A.zx - A.yx * A.zz;
184 C.yy = A.xx * A.zz - A.xz * A.zx;
185 C.yz = A.xz * A.yx - A.xx * A.yz;
186
187 C.zx = A.yx * A.zy - A.yy * A.zx;
188 C.zy = A.xy * A.zx - A.xx * A.zy;
189 C.zz = A.xx * A.yy - A.xy * A.yx;
190
191 if( w != 0.0 ) C /= w;
192
193 return C;
194}
double Det(void)
matrix determinant
Definition matr3d.h:114
void SetToZero(void)
reset matrix - set all components to zero
Definition matr3d.h:100

◆ v_fprintf() [1/2]

void v_fprintf ( FILE * dest,
char * fmt,
char * name,
const MATRIX_3x3 & mat )

print to sstream "dest" name and matrix components according to given format "fmt"

Definition at line 231 of file matr3d.cpp.

232{
233 fprintf( dest , fmt , name , mat.xx , mat.xy , mat.xz, mat.yx , mat.yy , mat.yz, mat.zx , mat.zy , mat.zz );
234}

◆ v_fprintf() [2/2]

void v_fprintf ( FILE * dest,
char * name,
const MATRIX_3x3 & mat )

print to stream "dest" name and matrix components

Definition at line 225 of file matr3d.cpp.

226{
227 fprintf(dest,"%s=[%19.11f,%19.11f %19.11f]\n[%19.11f,%19.11f,%19.11f]\n[%19.11f,%19.11f,%19.11f]\n",
228 name , mat.xx , mat.xy , mat.xz, mat.yx , mat.yy , mat.yz, mat.zx , mat.zy , mat.zz );
229}

◆ v_printf() [1/2]

void v_printf ( char * fmt,
char * name,
const MATRIX_3x3 & mat )

print to stdout name and matrix components according to given format "fmt"

Definition at line 209 of file matr3d.cpp.

210{
211 printf( fmt , name , mat.xx , mat.xy , mat.xz, mat.yx , mat.yy , mat.yz, mat.zx , mat.zy , mat.zz );
212}

◆ v_printf() [2/2]

void v_printf ( char * name,
const MATRIX_3x3 & mat )

print to stdout name and matrix components

Definition at line 203 of file matr3d.cpp.

204{
205 printf( "%s=[%19.11f,%19.11f,%19.11f]\n[%19.11f,%19.11f,%19.11f]\n[%19.11f,%19.11f,%19.11f]\n",
206 name , mat.xx , mat.xy , mat.xz, mat.yx , mat.yy , mat.yz, mat.zx , mat.zy , mat.zz );
207}

◆ v_sprintf() [1/2]

void v_sprintf ( char * dest,
char * fmt,
char * name,
const MATRIX_3x3 & mat )

print to string "dest" name and matrix components according to given format "fmt"

Definition at line 220 of file matr3d.cpp.

221{
222 sprintf(dest , fmt , name , mat.xx , mat.xy , mat.xz, mat.yx , mat.yy , mat.yz, mat.zx , mat.zy , mat.zz );
223}

◆ v_sprintf() [2/2]

void v_sprintf ( char * dest,
char * name,
const MATRIX_3x3 & mat )

print to string "dest" name and matrix components

Definition at line 214 of file matr3d.cpp.

215{
216 sprintf(dest,"%s=[%19.11f,%19.11f %19.11f][%19.11f,%19.11f,%19.11f][%19.11f,%19.11f,%19.11f]",
217 name , mat.xx , mat.xy , mat.xz, mat.yx , mat.yy , mat.yz, mat.zx , mat.zy , mat.zz );
218}