From 59ab37d509400d099c257ccf4ffe25db118dc75f Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 16 Jul 2018 20:06:09 +0200 Subject: [PATCH] improved vectodir and calcMousedest --- control.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/control.cpp b/control.cpp index 3ca79858..6f037531 100644 --- a/control.cpp +++ b/control.cpp @@ -53,20 +53,20 @@ bool mouseout2() { movedir vectodir(const hyperpoint& P) { - hyperpoint H = sphereflip * tC0(cwtV); - ld R = sqrt(H[0] * H[0] + H[1] * H[1]); - transmatrix Centered = sphereflip * cwtV; - if(!euclid) - Centered = gpushxto0(H) * Centered; - else if(R > 1e-9) - Centered = eupush(-H[0], -H[1]) * Centered; + transmatrix U = shmup::ggmatrix(cwt.c); + + hyperpoint H = sphereflip * tC0(U); + transmatrix Centered = rgpushxto0(H) * sphereflip; + ld binv = 99; - if(euclid) Centered = pispin * Centered; - ld dirdist[MAX_EDGE]; + for(int i=0; itype; i++) { - dirdist[i] = intval(Centered * ddspin(cwt.c, i, 0) * xpush(-.5) * C0, P); + transmatrix T; + if(compute_relamatrix(cwt.c->mov[fixdir(cwt.spin + i, cwt.c)], cwt.c, i, T)) { + dirdist[i] = intval(U * T * C0, Centered * P); + } //xspinpush0(-i * 2 * M_PI /cwt.c->type, .5), P); } @@ -109,8 +109,16 @@ void calcMousedest() { ld dists[MAX_EDGE]; - for(int i=0; itype; i++) - dists[i] = intval(mouseh, tC0(confusingGeometry() ? shmup::ggmatrix(cwt.c) * shmup::calc_relative_matrix(cwt.c->mov[i], cwt.c, i) : shmup::ggmatrix(cwt.c->mov[i]))); + transmatrix U = shmup::ggmatrix(cwt.c); + + for(int i=0; itype; i++) { + transmatrix T; + if(compute_relamatrix(cwt.c->mov[i], cwt.c, i, T)) + dists[i] = intval(mouseh, U * T * C0); + else + dists[i] = HUGE_VAL; + } + // confusingGeometry() ? shmup::ggmatrix(cwt.c) * shmup::calc_relative_matrix(cwt.c->mov[i], cwt.c, i) : shmup::ggmatrix(cwt.c->mov[i]))); /* printf("curcell = %Lf\n", mousedist); for(int i=0; itype; i++)