representation d'une transformation, une matrice 4x4, organisee par ligne / row major.
More...
#include <mat.h>
|
| Transform (const float t00=1.f, const float t01=0.f, const float t02=0.f, const float t03=0.f, const float t10=0.f, const float t11=1.f, const float t12=0.f, const float t13=0.f, const float t20=0.f, const float t21=0.f, const float t22=1.f, const float t23=0.f, const float t30=0.f, const float t31=0.f, const float t32=0.f, const float t33=1.f) |
| constructeur. More...
|
|
Point | operator() (const Point &p) const |
| renvoie le point transforme. More...
|
|
Vector | operator() (const Vector &v) const |
| renvoie le vecteur transforme. More...
|
|
vec4 | operator() (const vec4 &v) const |
| renvoie le point/vecteur homogene transforme. More...
|
|
Transform | transpose () const |
| renvoie la transposee de la matrice. More...
|
|
Transform | inverse () const |
| renvoie l'inverse de la matrice. More...
|
|
Transform | normal () const |
| renvoie la transformation a appliquer aux normales d'un objet transforme par la matrice m. More...
|
|
const float * | buffer () const |
| renvoie l'adresse de la premiere valeur de la matrice. More...
|
|
representation d'une transformation, une matrice 4x4, organisee par ligne / row major.
Definition at line 20 of file mat.h.
Transform::Transform |
( |
const float |
t00 = 1.f , |
|
|
const float |
t01 = 0.f , |
|
|
const float |
t02 = 0.f , |
|
|
const float |
t03 = 0.f , |
|
|
const float |
t10 = 0.f , |
|
|
const float |
t11 = 1.f , |
|
|
const float |
t12 = 0.f , |
|
|
const float |
t13 = 0.f , |
|
|
const float |
t20 = 0.f , |
|
|
const float |
t21 = 0.f , |
|
|
const float |
t22 = 1.f , |
|
|
const float |
t23 = 0.f , |
|
|
const float |
t30 = 0.f , |
|
|
const float |
t31 = 0.f , |
|
|
const float |
t32 = 0.f , |
|
|
const float |
t33 = 1.f |
|
) |
| |
constructeur.
Definition at line 23 of file mat.cpp.
29 m[0][0]= t00; m[0][1]= t01; m[0][2]= t02; m[0][3]= t03;
30 m[1][0]= t10; m[1][1]= t11; m[1][2]= t12; m[1][3]= t13;
31 m[2][0]= t20; m[2][1]= t21; m[2][2]= t22; m[2][3]= t23;
32 m[3][0]= t30; m[3][1]= t31; m[3][2]= t32; m[3][3]= t33;
Point Transform::operator() |
( |
const Point & |
p | ) |
const |
renvoie le point transforme.
Definition at line 36 of file mat.cpp.
42 float xt= m[0][0] * x + m[0][1] * y + m[0][2] * z + m[0][3];
43 float yt= m[1][0] * x + m[1][1] * y + m[1][2] * z + m[1][3];
44 float zt= m[2][0] * x + m[2][1] * y + m[2][2] * z + m[2][3];
45 float wt= m[3][0] * x + m[3][1] * y + m[3][2] * z + m[3][3];
50 return Point(xt, yt, zt);
52 return Point(xt*w, yt*w, zt*w);
representation d'un point 3d.
renvoie le vecteur transforme.
Definition at line 56 of file mat.cpp.
62 float xt= m[0][0] * x + m[0][1] * y + m[0][2] * z;
63 float yt= m[1][0] * x + m[1][1] * y + m[1][2] * z;
64 float zt= m[2][0] * x + m[2][1] * y + m[2][2] * z;
representation d'un vecteur 3d.
vec4 Transform::operator() |
( |
const vec4 & |
v | ) |
const |
renvoie le point/vecteur homogene transforme.
Definition at line 71 of file mat.cpp.
78 float xt= m[0][0] * x + m[0][1] * y + m[0][2] * z + m[0][3] * w;
79 float yt= m[1][0] * x + m[1][1] * y + m[1][2] * z + m[1][3] * w;
80 float zt= m[2][0] * x + m[2][1] * y + m[2][2] * z + m[2][3] * w;
81 float wt= m[3][0] * x + m[3][1] * y + m[3][2] * z + m[3][3] * w;
83 return vec4(xt, yt, zt, wt);
vecteur generique 4d, ou 3d homogene, utilitaire.
renvoie la transposee de la matrice.
Definition at line 87 of file mat.cpp.
90 m[0][0], m[1][0], m[2][0], m[3][0],
91 m[0][1], m[1][1], m[2][1], m[3][1],
92 m[0][2], m[1][2], m[2][2], m[3][2],
93 m[0][3], m[1][3], m[2][3], m[3][3]);
renvoie l'inverse de la matrice.
Definition at line 263 of file mat.cpp.
267 int indxc[4], indxr[4];
268 int ipiv[4] = { 0, 0, 0, 0 };
270 for (
int i = 0; i < 4; i++) {
271 int irow = -1, icol = -1;
275 for (
int j = 0; j < 4; j++) {
277 for (
int k = 0; k < 4; k++) {
279 if (fabsf(minv.m[j][k]) >= big) {
280 big = std::abs(minv.m[j][k]);
285 else if (ipiv[k] > 1)
286 printf(
"singular matrix in make_inverse()\n");
291 assert(irow >= 0 && irow < 4);
292 assert(icol >= 0 && icol < 4);
297 for (
int k = 0; k < 4; ++k)
298 std::swap(minv.m[irow][k], minv.m[icol][k]);
303 if (minv.m[icol][icol] == 0.)
304 printf(
"singular matrix in make_inverse()\n");
307 float pivinv = 1.f / minv.m[icol][icol];
308 minv.m[icol][icol] = 1.f;
309 for (
int j = 0; j < 4; j++)
310 minv.m[icol][j] *= pivinv;
313 for (
int j = 0; j < 4; j++) {
315 float save = minv.m[j][icol];
317 for (
int k = 0; k < 4; k++)
318 minv.m[j][k] -= minv.m[icol][k]*save;
324 for (
int j = 3; j >= 0; j--) {
325 if (indxr[j] != indxc[j]) {
326 for (
int k = 0; k < 4; k++)
327 std::swap(minv.m[k][indxr[j]], minv.m[k][indxc[j]]);
void printf(Text &text, const int px, const int py, const char *format,...)
affiche un texte a la position x, y. meme utilisation que printf().
renvoie la transformation a appliquer aux normales d'un objet transforme par la matrice m.
Definition at line 97 of file mat.cpp.
const float* Transform::buffer |
( |
| ) |
const |
|
inline |
renvoie l'adresse de la premiere valeur de la matrice.
Definition at line 44 of file mat.h.
The documentation for this struct was generated from the following files: