1 /** 2 * @file lv_matrix.h 3 * 4 */ 5 6 #ifndef LV_MATRIX_H 7 #define LV_MATRIX_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 17 #include "../lv_conf_internal.h" 18 19 #if LV_USE_MATRIX 20 21 #include "lv_types.h" 22 #include "lv_area.h" 23 24 /********************* 25 * DEFINES 26 *********************/ 27 28 #if !LV_USE_FLOAT 29 #error "LV_USE_FLOAT is required for lv_matrix" 30 #endif 31 32 /********************** 33 * TYPEDEFS 34 **********************/ 35 36 struct _lv_matrix_t { 37 float m[3][3]; 38 }; 39 40 /********************** 41 * GLOBAL PROTOTYPES 42 **********************/ 43 44 /** 45 * Set matrix to identity matrix 46 * @param matrix pointer to a matrix 47 */ 48 void lv_matrix_identity(lv_matrix_t * matrix); 49 50 /** 51 * Translate the matrix to new position 52 * @param matrix pointer to a matrix 53 * @param tx the amount of translate in x direction 54 * @param tx the amount of translate in y direction 55 */ 56 void lv_matrix_translate(lv_matrix_t * matrix, float tx, float ty); 57 58 /** 59 * Change the scale factor of the matrix 60 * @param matrix pointer to a matrix 61 * @param scale_x the scale factor for the X direction 62 * @param scale_y the scale factor for the Y direction 63 */ 64 void lv_matrix_scale(lv_matrix_t * matrix, float scale_x, float scale_y); 65 66 /** 67 * Rotate the matrix with origin 68 * @param matrix pointer to a matrix 69 * @param degree angle to rotate 70 */ 71 void lv_matrix_rotate(lv_matrix_t * matrix, float degree); 72 73 /** 74 * Change the skew factor of the matrix 75 * @param matrix pointer to a matrix 76 * @param skew_x the skew factor for x direction 77 * @param skew_y the skew factor for y direction 78 */ 79 void lv_matrix_skew(lv_matrix_t * matrix, float skew_x, float skew_y); 80 81 /** 82 * Multiply two matrix and store the result to the first one 83 * @param matrix pointer to a matrix 84 * @param matrix2 pointer to another matrix 85 */ 86 void lv_matrix_multiply(lv_matrix_t * matrix, const lv_matrix_t * mul); 87 88 /** 89 * Invert the matrix 90 * @param matrix pointer to a matrix 91 * @param m pointer to another matrix (optional) 92 * @return true: the matrix is invertible, false: the matrix is singular and cannot be inverted 93 */ 94 bool lv_matrix_inverse(lv_matrix_t * matrix, const lv_matrix_t * m); 95 96 /** 97 * Transform a point by a matrix 98 * @param matrix pointer to a matrix 99 * @param point pointer to a point 100 * @return the transformed point 101 */ 102 lv_point_precise_t lv_matrix_transform_precise_point(const lv_matrix_t * matrix, const lv_point_precise_t * point); 103 104 /** 105 * Transform an area by a matrix 106 * @param matrix pointer to a matrix 107 * @param area pointer to an area 108 * @return the transformed area 109 */ 110 lv_area_t lv_matrix_transform_area(const lv_matrix_t * matrix, const lv_area_t * area); 111 112 /** 113 * Check if the matrix is identity or translation matrix 114 * @param matrix pointer to a matrix 115 * @return true: the matrix is identity or translation matrix, false: the matrix is not identity or translation matrix 116 */ 117 bool lv_matrix_is_identity_or_translation(const lv_matrix_t * matrix); 118 119 /********************** 120 * MACROS 121 **********************/ 122 123 #endif /*LV_USE_MATRIX*/ 124 125 #ifdef __cplusplus 126 } /*extern "C"*/ 127 #endif 128 129 #endif /*LV_MATRIX_H*/ 130