mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 20:18:22 +08:00
add matrix_is_invertible
This commit is contained in:
parent
775b4f479f
commit
493376c767
15
src/tkc/matrix.c
Executable file → Normal file
15
src/tkc/matrix.c
Executable file → Normal file
@ -145,3 +145,18 @@ matrix_t* matrix_transform_pointf(matrix_t* m, float x, float y, float* ox, floa
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
static double matrix_compute_determinant(matrix_t* m) {
|
||||
double a = m->a0;
|
||||
double b = m->a1;
|
||||
double c = m->a2;
|
||||
double d = m->a3;
|
||||
|
||||
return a * d - b * c;
|
||||
}
|
||||
|
||||
bool_t matrix_is_invertible(matrix_t* m) {
|
||||
double det = matrix_compute_determinant(m);
|
||||
|
||||
return TK_ISFINITE(det) && det != 0.;
|
||||
}
|
||||
|
@ -159,6 +159,16 @@ matrix_t* matrix_transform_point(matrix_t* m, xy_t x, xy_t y, xy_t* out_x, xy_t*
|
||||
*/
|
||||
matrix_t* matrix_transform_pointf(matrix_t* m, float x, float y, float* ox, float* oy);
|
||||
|
||||
/**
|
||||
* @method matrix_is_invertible
|
||||
* 判断matrix是否可逆。
|
||||
*
|
||||
* @param {matrix_t*} m 矩阵对象。
|
||||
*
|
||||
* @return {bool_t} 返回TRUE表示可逆,否则表示不可逆。
|
||||
*/
|
||||
bool_t matrix_is_invertible(matrix_t* m);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_MATRIX_H*/
|
||||
|
Loading…
Reference in New Issue
Block a user