From 60bf28f359823b70ba0f7e7e3cd4624099704b4a Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 7 Aug 2019 20:03:50 +0200 Subject: [PATCH] transmatrix back to old definition (some weird bugs?) but improved --- drawing.cpp | 14 ++++++++++++-- hyper.h | 26 +++++++++----------------- hyperpoint.cpp | 14 +++++++++++--- rug.cpp | 8 ++++++-- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/drawing.cpp b/drawing.cpp index 1dea8813..e381735f 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -349,8 +349,18 @@ void filledPolygonColorI(SDL_Surface *s, int* px, int *py, int polyi, color_t co #if CAP_TEXTURE void drawTexturedTriangle(SDL_Surface *s, int *px, int *py, glvertex *tv, color_t col) { - transmatrix source( point3(px[0], px[1], px[2]), point3(py[0], py[1], py[2]), point3(1,1,1), point31(0,0,0) ); - transmatrix target( point3(tv[0][0], tv[1][0], tv[2][0]), point3(tv[0][1],tv[1][1],tv[2][1]), point3(1,1,1), point31(0,0,0) ); + transmatrix source = matrix3( + px[0], px[1], px[2], + py[0], py[1], py[2], + 1, 1, 1); + + + transmatrix target = matrix3( + tv[0][0], tv[1][0], tv[2][0], + tv[0][1], tv[1][1], tv[2][1], + 1, 1, 1 + ); + transmatrix isource = inverse(source); int minx = px[0], maxx = px[0]; int miny = py[0], maxy = py[0]; diff --git a/hyper.h b/hyper.h index 3fe70731..674fa6c2 100644 --- a/hyper.h +++ b/hyper.h @@ -348,14 +348,10 @@ struct hyperpoint : array { } }; -struct transmatrix : array { - transmatrix() {} - transmatrix(hyperpoint a, hyperpoint b, hyperpoint c, hyperpoint d) { - (*this)[0] = a; - (*this)[1] = b; - (*this)[2] = c; - (*this)[3] = d; - } +struct transmatrix { + ld tab[MAXMDIM][MAXMDIM]; + hyperpoint& operator [] (int i) { return (hyperpoint&)tab[i][0]; } + const ld * operator [] (int i) const { return tab[i]; } }; inline hyperpoint operator * (const transmatrix& T, const hyperpoint& H) { @@ -377,16 +373,12 @@ inline transmatrix operator * (const transmatrix& T, const transmatrix& U) { return R; } -inline transmatrix diag(ld a, ld b, ld c, ld d) { - transmatrix T; - for(int i=0; i= 4 diff --git a/rug.cpp b/rug.cpp index 1599d6f8..6eb2134d 100644 --- a/rug.cpp +++ b/rug.cpp @@ -454,13 +454,17 @@ void buildTorusRug() { // 22,1 // 7,-17 + transmatrix z1 = matrix3( + solution.first.x, solution.second.x, 0, + solution.first.y, solution.second.y, 0, + 0, 0, 1); // transmatrix z1 = {{{22,7,0}, {1,-17,0}, {0,0,1}}}; - transmatrix z1( + /* transmatrix z1( point3(solution.first.x, solution.second.x, 0), point3(solution.first.y, solution.second.y, 0), point3(0, 0, 1), point31(0, 0, 0) - ); + ); */ transmatrix z2 = inverse(z1); if(gwhere == gSphere) {