-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathdq_mat3.h
142 lines (139 loc) · 3.26 KB
/
dq_mat3.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#ifndef _MAT3_H
# define _MAT3_H
/**
* @file dq_mat3.h
*
* @brief File containing functions related to 3 by 3 matrix.
*/
/**
* @defgroup mat3 Auxiliary 3x3 Matrix Functions
* @brief Set of auxiliary functions to manipulate 3x3 matrix.
*/
/** @{ */
/**
* @brief Creates an identity 3x3 matrix.
*
* \f[
* M = \left( \begin{array}{ccc}
* 1 & 0 & 0 \\
* 0 & 1 & 0 \\
* 0 & 0 & 1
* \end{array} \right)
* \f]
*
* @param[out] M An identiy matrix.
*/
void mat3_eye( double M[3][3] );
/**
* @brief Gets the determinant of a 3x3 3x3 3x3 matrix.
*
* \f[
* o = \| M \|
* \f]
*
* @param[in] M 3x3 Matrix to get the determinant of.
* @return The determinant of the 3x3 matrix.
*/
double mat3_det( double M[3][3] );
/**
* @brief Adds two 3x3 matrix.
*
* \f[
* out = A + B
* \f]
*
* @param[out] out Result of the 3x3 matrix addition.
* @param[in] A First matrix to operate on.
* @param[in] B Second matrix to operate on.
*/
void mat3_add( double out[3][3], double A[3][3], double B[3][3] );
/**
* @brief Subtracts two 3x3 matrix.
*
* \f[
* out = A - B
* \f]
*
* @param[out] out Result of the 3x3 matrix subtraction.
* @param[in] A First matrix to operate on.
* @param[in] B Second matrix to operate on.
*/
void mat3_sub( double out[3][3], double A[3][3], double B[3][3] );
/**
* @brief Inverts a 3x3 matrix.
*
* \f[
* out = in^{-1}
* \f]
*
* @param[out] out Inversion of the matrix.
* @param[in] in Matrix to invert.
*/
void mat3_inv( double out[3][3], double in[3][3] );
/**
* @brief Multiplies two 3x3 matrix.
*
* \f[
* AB = A * B
* \f]
*
* @param[out] AB Result of the matrix multiplication.
* @param[in] A First matrix to operate on.
* @param[in] B Second matrix to operate on.
*/
void mat3_mul( double AB[3][3], double A[3][3], double B[3][3] );
/**
* @brief Multiplies a 3x3 matrix by a vector.
*
* \f[
* out = M * v
* \f]
*
* @param[out] out Result of the multiplication.
* @param[in] M Matrix to operate on.
* @param[in] v Vector to operate on.
*/
void mat3_mul_vec( double out[3], double M[3][3], const double v[3] );
/**
* @brief Solves a 3x3 equation system.
*
* Equation system should be in the form of:
*
* \f[
* A x = b
* \f]
*
* Uses Cramer's rule to solve the system.
*
* The system should be solveable (\f$ det(A) \neq 0 \f$).
*
* @param[out] x Vector of variables to solve.
* @param[in] A Matrix of coefficients.
* @param[in] b Independent variable matrix.
*/
void mat3_solve( double x[3], double A[3][3], const double b[3] );
/**
* @brief Compares two 3x3 matrix.
*
* @param[in] A First matrix to compare.
* @param[in] B Second matrix to compare.
* @return 0 if they are the same.
*/
int mat3_cmp( double A[3][3], double B[3][3] );
/**
* @brief Compares two 3x3 matrix with custom precision.
*
* @param[in] A First matrix to compare.
* @param[in] B Second matrix to compare.
* @param[in] precision Precision to use when comparing.
* @return 0 if they are the same.
*/
int mat3_cmpV( double A[3][3], double B[3][3], double precision );
/**
* @brief Prints the value of a matrix on screen.
*
* @param[in] M Matrix to print.
*/
void mat3_print( double M[3][3] );
/** @} */
#endif /* _MAT3_H */