1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2025-04-21 12:27:27 +03:00

Initial commit. For older history, see project ben-scans.

http://projects.qi-hardware.com/index.php/p/ben-scans/
This commit is contained in:
Werner Almesberger
2010-09-25 04:46:16 -03:00
commit e8d6837065
23 changed files with 2139 additions and 0 deletions

45
solidify/matrix.h Normal file
View File

@@ -0,0 +1,45 @@
/*
* matrix.h - 2D matrix operations
*
* Written 2010 by Werner Almesberger
* Copyright 2010 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef MATRIX_H
#define MATRIX_H
/*
* 2D transformation:
*
* x' = x*a[0][0]+y*a[0][1]+b[0]
* y' = x*a[1][0]+y*a[1][1]+b[1]
*/
struct matrix {
double a[2][2];
double b[2];
};
void matrix_identity(struct matrix *m);
void matrix_invert(const double m[2][2], double res[2][2]);
void matrix_mult(double a[2][2], double b[2][2], double res[2][2]);
void matrix_multv(const double v[2], double m[2][2], double res[2]);
void matrix_copy(double from[2][2], double to[2][2]);
static inline void matrix_map(int x, int y, const struct matrix *m,
double *res_x, double *res_y)
{
*res_x = x*m->a[0][0]+y*m->a[0][1]+m->b[0];
*res_y = x*m->a[1][0]+y*m->a[1][1]+m->b[1];
}
#endif /* !MATRIX_H */