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
|
/**
* @file lv_matrix.h
*
*/
#ifndef LV_MATRIX_H
#define LV_MATRIX_H
#ifdef __cplusplus
extern "C" {
#endif
/*********************
* INCLUDES
*********************/
#include "../lv_conf_internal.h"
#if LV_USE_MATRIX
#include "lv_types.h"
#include "lv_area.h"
/*********************
* DEFINES
*********************/
#if !LV_USE_FLOAT
#error "LV_USE_FLOAT is required for lv_matrix"
#endif
/**********************
* TYPEDEFS
**********************/
struct lv_matrix_t {
float m[3][3];
};
/**********************
* GLOBAL PROTOTYPES
**********************/
/**
* Set matrix to identity matrix
* @param matrix pointer to a matrix
*/
void lv_matrix_identity(lv_matrix_t * matrix);
/**
* Translate the matrix to new position
* @param matrix pointer to a matrix
* @param tx the amount of translate in x direction
* @param tx the amount of translate in y direction
*/
void lv_matrix_translate(lv_matrix_t * matrix, float tx, float ty);
/**
* Change the scale factor of the matrix
* @param matrix pointer to a matrix
* @param scale_x the scale factor for the X direction
* @param scale_y the scale factor for the Y direction
*/
void lv_matrix_scale(lv_matrix_t * matrix, float scale_x, float scale_y);
/**
* Rotate the matrix with origin
* @param matrix pointer to a matrix
* @param degree angle to rotate
*/
void lv_matrix_rotate(lv_matrix_t * matrix, float degree);
/**
* Change the skew factor of the matrix
* @param matrix pointer to a matrix
* @param skew_x the skew factor for x direction
* @param skew_y the skew factor for y direction
*/
void lv_matrix_skew(lv_matrix_t * matrix, float skew_x, float skew_y);
/**
* Multiply two matrix and store the result to the first one
* @param matrix pointer to a matrix
* @param matrix2 pointer to another matrix
*/
void lv_matrix_multiply(lv_matrix_t * matrix, const lv_matrix_t * mul);
/**
* Invert the matrix
* @param matrix pointer to a matrix
* @param m pointer to another matrix (optional)
* @return true: the matrix is invertible, false: the matrix is singular and cannot be inverted
*/
bool lv_matrix_inverse(lv_matrix_t * matrix, const lv_matrix_t * m);
/**
* Transform a point by a matrix
* @param matrix pointer to a matrix
* @param point pointer to a point
* @return the transformed point
*/
lv_point_precise_t lv_matrix_transform_precise_point(const lv_matrix_t * matrix, const lv_point_precise_t * point);
/**
* Transform an area by a matrix
* @param matrix pointer to a matrix
* @param area pointer to an area
* @return the transformed area
*/
lv_area_t lv_matrix_transform_area(const lv_matrix_t * matrix, const lv_area_t * area);
/**
* Check if the matrix is identity or translation matrix
* @param matrix pointer to a matrix
* @return true: the matrix is identity or translation matrix, false: the matrix is not identity or translation matrix
*/
bool lv_matrix_is_identity_or_translation(const lv_matrix_t * matrix);
/**********************
* MACROS
**********************/
#endif /*LV_USE_MATRIX*/
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*LV_MATRIX_H*/
|