mirror of
git://projects.qi-hardware.com/ben-scans.git
synced 2024-11-22 07:14:59 +02:00
898970b3dd
them once. - solidify/matrix.h, solidify/matrix.c: 2D matrix operations - solidify/Makefile (OBJS): added matrix.o - solidify/face.h (struct matrix): moved to solidify/matrix.h - solidify/overlap.c (point, merge_matrix, draw_map): precalculate a single vA+b transformation instead of stepwise transforming the vector inside the loop - solidify/overlap.c (do_shift): now that the math is right (or at least better), reverse the shift
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
/*
|
|
* 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 */
|