CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
matr3d.h
Go to the documentation of this file.
1/*********************************************************************/
2/* */
3/* Config files library - (C) TGG 2019 */
4/* */
5/*********************************************************************/
6/* Warszawa, 2019 */
7/*********************************************************************/
8/* */
9/* File: matr3d.h */
10/* */
11/* Author: F.A.Dul, modif. by T.Grabowski */
12/* */
13/* Contents - matrix 3x3 class */
14/* */
15/* */
16/*********************************************************************/
17/* */
18/* */
19
24#ifndef _MATR_3D_H_
25#define _MATR_3D_H_
26
27#include "vector3d.h"
28
39
41{
42 public:
43// row-column indices, e.g., xz --> 0,2
44 double xx;
45 double xy;
46 double xz;
47 double yx;
48 double yy;
49 double yz;
50 double zx;
51 double zy;
52 double zz;
53
55 MATRIX_3x3( void ){ SetToZero(); };
57 MATRIX_3x3( double xx_p , double xy_p , double xz_p ,
58 double yx_p , double yy_p , double yz_p ,
59 double zx_p , double zy_p , double zz_p ) :
60 xx(xx_p) , xy(xy_p) , xz(xz_p) ,
61 yx(yx_p) , yy(yy_p) , yz(yz_p) ,
62 zx(zx_p) , zy(zy_p) , zz(zz_p)
63 {};
65 MATRIX_3x3( double M[] ) :
66 xx(M[0]) , xy(M[3]) , xz(M[6]) ,
67 yx(M[1]) , yy(M[4]) , yz(M[7]) ,
68 zx(M[2]) , zy(M[5]) , zz(M[8])
69 {};
71 MATRIX_3x3( double M[3][3] ) :
72 xx(M[0][0]) , xy(M[0][1]) , xz(M[0][2]) ,
73 yx(M[1][0]) , yy(M[1][1]) , yz(M[1][2]) ,
74 zx(M[2][0]) , zy(M[2][1]) , zz(M[2][2])
75 {};
77 void GetFrom ( double xx_p , double xy_p , double xz_p ,
78 double yx_p , double yy_p , double yz_p ,
79 double zx_p , double zy_p , double zz_p )
80 {
81 xx = xx_p; xy = xy_p; xz = xz_p;
82 yx = yx_p; yy = yy_p; yz = yz_p;
83 zx = zx_p; zy = zy_p; zz = zz_p;
84 };
86 void GetFrom( double A[] )
87 {
88 xx = A[0]; xy = A[1]; xz = A[2];
89 yx = A[3]; yy = A[4]; yz = A[5];
90 zx = A[6]; zy = A[7]; zz = A[8];
91 };
93 void GetFrom( double A[3][3] )
94 {
95 xx = A[0][0]; xy = A[0][1]; xz = A[0][2];
96 yx = A[1][0]; yy = A[1][1]; yz = A[1][2];
97 zx = A[2][0]; zy = A[2][1]; zz = A[2][2];
98 };
100 void SetToZero( void )
101 {
102 xx = 0.0; xy = 0.0; xz = 0.0;
103 yx = 0.0; yy = 0.0; yz = 0.0;
104 zx = 0.0; zy = 0.0; zz = 0.0;
105 };
107 void Unit( void )
108 {
109 xx = 1.0; xy = 0.0; xz = 0.0;
110 yx = 0.0; yy = 1.0; yz = 0.0;
111 zx = 0.0; zy = 0.0; zz = 1.0;
112 };
114 double Det( void )
115 {
116 return xz*yy*zx + xx*yz*zy + xy*yx*zz;
117 };
118};
119
121
123MATRIX_3x3 operator *( const MATRIX_3x3 &A , const MATRIX_3x3 &B );
125MATRIX_3x3 operator &( const MATRIX_3x3 &A , const MATRIX_3x3 &B );
131MATRIX_3x3 operator *( const MATRIX_3x3 &A , const double &s );
133MATRIX_3x3 operator *( const double &s , const MATRIX_3x3 &A );
135MATRIX_3x3 operator /( const MATRIX_3x3 &A , const double &s );
137MATRIX_3x3 operator +( const MATRIX_3x3 &A , const MATRIX_3x3 &B );
139MATRIX_3x3 operator -( const MATRIX_3x3 &A , const MATRIX_3x3 &B );
143void operator /=( MATRIX_3x3 &A , const double &s );
144
146VECTOR_3D operator *( const MATRIX_3x3 &A , const VECTOR_3D &b );
148VECTOR_3D operator *( const VECTOR_3D &b , const MATRIX_3x3 &A );
151
153
155void v_printf( char *name , const MATRIX_3x3 &mat );
157void v_printf( char *fmt , char *name , const MATRIX_3x3 &mat );
159void v_sprintf( char *dest , char *name , const MATRIX_3x3 &mat );
161void v_sprintf( char *dest , char *fmt , char *name , const MATRIX_3x3 &mat );
163void v_fprintf( FILE *dest , char *name , const MATRIX_3x3 &mat );
165void v_fprintf( FILE *dest , char *fmt , char *name , const MATRIX_3x3 &mat );
167std::ostream & operator << ( std::ostream & out, const MATRIX_3x3 &mat );
168
169#endif /*_MATR_3D_H_*/
MATRIX_3x3 class and functions.
Definition matr3d.h:41
void GetFrom(double A[])
copies components values from the array (one dimensional)
Definition matr3d.h:86
double yy
(1,1) element
Definition matr3d.h:48
double xx
(0,0) element
Definition matr3d.h:44
MATRIX_3x3(double xx_p, double xy_p, double xz_p, double yx_p, double yy_p, double yz_p, double zx_p, double zy_p, double zz_p)
constructor - sets components values from variables
Definition matr3d.h:57
double zz
(2,2) element
Definition matr3d.h:52
void GetFrom(double xx_p, double xy_p, double xz_p, double yx_p, double yy_p, double yz_p, double zx_p, double zy_p, double zz_p)
copies components values from variables
Definition matr3d.h:77
MATRIX_3x3(void)
default constructor - sets components to zero
Definition matr3d.h:55
void Unit(void)
set unit matrix
Definition matr3d.h:107
double yz
(1,2) element
Definition matr3d.h:49
double Det(void)
matrix determinant
Definition matr3d.h:114
double zx
(2,0) element
Definition matr3d.h:50
void GetFrom(double A[3][3])
copies components values from the array (two dimensional)
Definition matr3d.h:93
double yx
(1,0) element
Definition matr3d.h:47
MATRIX_3x3(double M[3][3])
constructor - sets components values from the array (two dimensional)
Definition matr3d.h:71
double xz
(0,2) element
Definition matr3d.h:46
double xy
(0,1) element
Definition matr3d.h:45
MATRIX_3x3(double M[])
constructor - sets components values from the array (one dimensional)
Definition matr3d.h:65
void SetToZero(void)
reset matrix - set all components to zero
Definition matr3d.h:100
double zy
(2,1) element
Definition matr3d.h:51
Vector 3D class - vector manipulation.
Definition vector3d.h:34
MATRIX_3x3 operator-(const MATRIX_3x3 &A, const MATRIX_3x3 &B)
Arithmetic operator - subtraction of 2 matrices (sum of A and -B)
Definition matr3d.cpp:75
MATRIX_3x3 operator*(const MATRIX_3x3 &A, const MATRIX_3x3 &B)
Arithmetic operator - multiplication of 2 matrices.
Definition matr3d.cpp:152
MATRIX_3x3 operator~(const MATRIX_3x3 &A)
Arithmetic operator - matrix inversion ( A^(-1) )
Definition matr3d.cpp:171
void v_sprintf(char *dest, char *name, const MATRIX_3x3 &mat)
print to string "dest" name and matrix components
Definition matr3d.cpp:214
void v_printf(char *name, const MATRIX_3x3 &mat)
print to stdout name and matrix components
Definition matr3d.cpp:203
std::ostream & operator<<(std::ostream &out, const MATRIX_3x3 &mat)
print to std:ostream
MATRIX_3x3 operator+(const MATRIX_3x3 &A, const MATRIX_3x3 &B)
Arithmetic operator - sum of 2 matrices.
Definition matr3d.cpp:63
void v_fprintf(FILE *dest, char *name, const MATRIX_3x3 &mat)
print to stream "dest" name and matrix components
Definition matr3d.cpp:225
MATRIX_3x3 operator/(const MATRIX_3x3 &A, const double &s)
Arithmetic operator - division of matrix by scalar (product of matrix and 1/s)
Definition matr3d.cpp:124
MATRIX_3x3 operator!(const MATRIX_3x3 &A)
Arithmetic operator - matrix transposition ( A^T )
Definition matr3d.cpp:142
MATRIX_3x3 operator&(const MATRIX_3x3 &A, const MATRIX_3x3 &B)
Arithmetic operator - multiplication of 2 matrices components ( AxxBxx, AxyBxy, .....
Definition matr3d.cpp:51
void operator/=(MATRIX_3x3 &A, const double &s)
Arithmetic operator - division assignment.
Definition matr3d.cpp:135
Vector 3D class and functions.