hal_gfx_matrix3x3.h
Go to the documentation of this file.
1 
2 
3 /** @addtogroup GRAPHICS_SDK Graphics
4  * @{
5  */
6 
7 /** @defgroup HAL_GFX_MATRIX3X3 Hal gfx matrix3x3
8  * @brief Base matrix3x3 Operation.
9  * @{
10  */
11 
12 #ifndef HAL_GFX_MATRIX3X3_H__
13 #define HAL_GFX_MATRIX3X3_H__
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /**
20  * @defgroup HAL_GFX_MATRIX3X3_TYPEDEF Typedefs
21  * @{
22  */
23 typedef float hal_gfx_matrix3x3_t[3][3]; /**< Global define matrix3x3 variable. */
24 /** @} */
25 
26 /**
27  * @defgroup HAL_GFX_MATRIX3X3_FUNCTION Functions
28  * @{
29  */
30 /**
31  *****************************************************************************************
32  * @brief Load Identity Matrix
33  *
34  * @param[in] m: Matrix to be loaded
35  *****************************************************************************************
36  */
38 
39 /**
40  *****************************************************************************************
41  * @brief Apply translate transformation
42  *
43  * @param[in] m: Matrix to apply transformation
44  * @param[in] tx: X translation factor
45  * @param[in] ty: Y translation factor
46  *****************************************************************************************
47  */
48 void hal_gfx_mat3x3_translate (hal_gfx_matrix3x3_t m, float tx, float ty);
49 
50 /**
51  *****************************************************************************************
52  * @brief Apply scale transformation
53  *
54  * @param[in] m: Matrix to apply transformation
55  * @param[in] sx: X scaling factor
56  * @param[in] sy: Y scaling factor
57  *****************************************************************************************
58  */
59 void hal_gfx_mat3x3_scale (hal_gfx_matrix3x3_t m, float sx, float sy);
60 
61 /**
62  *****************************************************************************************
63  * @brief Apply shear transformation
64  *
65  * @param[in] m: Matrix to apply transformation
66  * @param[in] shx: X shearing factor
67  * @param[in] shy: Y shearing factor
68  *****************************************************************************************
69  */
70 void hal_gfx_mat3x3_shear (hal_gfx_matrix3x3_t m, float shx, float shy);
71 
72 /**
73  *****************************************************************************************
74  * @brief Apply mirror transformation
75  *
76  * @param[in] m: Matrix to apply transformation
77  * @param[in] mx: if non-zero, mirror horizontally
78  * @param[in] my: if non-zero, mirror vertically
79  *****************************************************************************************
80  */
81 void hal_gfx_mat3x3_mirror (hal_gfx_matrix3x3_t m, int mx, int my);
82 
83 /**
84  *****************************************************************************************
85  * @brief Apply rotation transformation
86  *
87  * @param[in] m: Matrix to apply transformation
88  * @param[in] angle_degrees: Angle to rotate in degrees
89  *****************************************************************************************
90  */
91 void hal_gfx_mat3x3_rotate (hal_gfx_matrix3x3_t m, float angle_degrees);
92 
93 /**
94  *****************************************************************************************
95  * @brief Multiply two 3x3 matrices ( m = m*_m)
96  *
97  * @param[in] m: left matrix, will be overwritten by the result
98  * @param[in] _m: right matrix
99  *****************************************************************************************
100  */
102 
103 /**
104  *****************************************************************************************
105  * @brief Multiply vector with matrix
106  *
107  * @param[in] m: Matrix to multiply with
108  * @param[in] x: Vector x coefficient
109  * @param[in] y: Vector y coefficient
110  *****************************************************************************************
111  */
112 void hal_gfx_mat3x3_mul_vec(hal_gfx_matrix3x3_t m, float *x, float *y);
113 
114 /**
115  *****************************************************************************************
116  * @brief Multiply vector with affine matrix
117  *
118  * @param[in] m: Matrix to multiply with
119  * @param[in] x: Vector x coefficient
120  * @param[in] y: Vector y coefficient
121  *****************************************************************************************
122  */
124 
125 /**
126  *****************************************************************************************
127  * @brief Calculate adjoint
128  *
129  * @param[in] m: Matrix
130  *****************************************************************************************
131  */
133 
134 /**
135  *****************************************************************************************
136  * @brief Divide matrix with scalar value
137  *
138  * @param[in] m: Matrix to divide
139  * @param[in] s: scalar value
140  *****************************************************************************************
141  */
143 
144 /**
145  *****************************************************************************************
146  * @brief Invert matrix
147  *
148  * @param[in] m: Matrix to invert
149  *****************************************************************************************
150  */
152 
153 /**
154  *****************************************************************************************
155  * @brief Square to quad transformation
156  *
157  * @param[in] dx0: x coordinate at the first vertex of the quadrilateral
158  * @param[in] dy0: y coordinate at the first vertex of the quadrilateral
159  * @param[in] dx1: x coordinate at the second vertex of the quadrilateral
160  * @param[in] dy1: y coordinate at the second vertex of the quadrilateral
161  * @param[in] dx2: x coordinate at the third vertex of the quadrilateral
162  * @param[in] dy2: y coordinate at the third vertex of the quadrilateral
163  * @param[in] dx3: x coordinate at the fourth vertex of the quadrilateral
164  * @param[in] dy3: y coordinate at the fourth vertex of the quadrilateral
165  * @param[in] m: Store converted matrix
166  *****************************************************************************************
167  */
168 int hal_gfx_mat3x3_square_to_quad(float dx0, float dy0,
169  float dx1, float dy1,
170  float dx2, float dy2,
171  float dx3, float dy3,
173 
174 /**
175  *****************************************************************************************
176  * @brief Map rectangle to quadrilateral
177  *
178  * @param[in] width: Rectangle width
179  * @param[in] height: Rectangle height
180  * @param[in] sx0: x coordinate at the first vertex of the quadrilateral
181  * @param[in] sy0: y coordinate at the first vertex of the quadrilateral
182  * @param[in] sx1: x coordinate at the second vertex of the quadrilateral
183  * @param[in] sy1: y coordinate at the second vertex of the quadrilateral
184  * @param[in] sx2: x coordinate at the third vertex of the quadrilateral
185  * @param[in] sy2: y coordinate at the third vertex of the quadrilateral
186  * @param[in] sx3: x coordinate at the fourth vertex of the quadrilateral
187  * @param[in] sy3: y coordinate at the fourth vertex of the quadrilateral
188  * @param[in] m: Mapping matrix
189  *****************************************************************************************
190  */
191 int hal_gfx_mat3x3_quad_to_rect(int width, int height,
192  float sx0, float sy0,
193  float sx1, float sy1,
194  float sx2, float sy2,
195  float sx3, float sy3,
197 /** @} */
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 #endif
203 /** @} */
204 /** @} */
hal_gfx_mat3x3_div_scalar
void hal_gfx_mat3x3_div_scalar(hal_gfx_matrix3x3_t m, float s)
Divide matrix with scalar value.
hal_gfx_mat3x3_mul_vec_affine
void hal_gfx_mat3x3_mul_vec_affine(hal_gfx_matrix3x3_t m, float *x, float *y)
Multiply vector with affine matrix.
hal_gfx_mat3x3_rotate
void hal_gfx_mat3x3_rotate(hal_gfx_matrix3x3_t m, float angle_degrees)
Apply rotation transformation.
hal_gfx_mat3x3_load_identity
void hal_gfx_mat3x3_load_identity(hal_gfx_matrix3x3_t m)
Load Identity Matrix.
hal_gfx_mat3x3_square_to_quad
int hal_gfx_mat3x3_square_to_quad(float dx0, float dy0, float dx1, float dy1, float dx2, float dy2, float dx3, float dy3, hal_gfx_matrix3x3_t m)
Square to quad transformation.
hal_gfx_mat3x3_adj
void hal_gfx_mat3x3_adj(hal_gfx_matrix3x3_t m)
Calculate adjoint.
hal_gfx_mat3x3_mirror
void hal_gfx_mat3x3_mirror(hal_gfx_matrix3x3_t m, int mx, int my)
Apply mirror transformation.
hal_gfx_mat3x3_mul
void hal_gfx_mat3x3_mul(hal_gfx_matrix3x3_t m, hal_gfx_matrix3x3_t _m)
Multiply two 3x3 matrices ( m = m*_m)
hal_gfx_mat3x3_invert
int hal_gfx_mat3x3_invert(hal_gfx_matrix3x3_t m)
Invert matrix.
hal_gfx_mat3x3_quad_to_rect
int hal_gfx_mat3x3_quad_to_rect(int width, int height, float sx0, float sy0, float sx1, float sy1, float sx2, float sy2, float sx3, float sy3, hal_gfx_matrix3x3_t m)
Map rectangle to quadrilateral.
hal_gfx_mat3x3_translate
void hal_gfx_mat3x3_translate(hal_gfx_matrix3x3_t m, float tx, float ty)
Apply translate transformation.
hal_gfx_mat3x3_scale
void hal_gfx_mat3x3_scale(hal_gfx_matrix3x3_t m, float sx, float sy)
Apply scale transformation.
hal_gfx_matrix3x3_t
float hal_gfx_matrix3x3_t[3][3]
Definition: hal_gfx_matrix3x3.h:23
hal_gfx_mat3x3_mul_vec
void hal_gfx_mat3x3_mul_vec(hal_gfx_matrix3x3_t m, float *x, float *y)
Multiply vector with matrix.
hal_gfx_mat3x3_shear
void hal_gfx_mat3x3_shear(hal_gfx_matrix3x3_t m, float shx, float shy)
Apply shear transformation.