1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-23 13:07:16 +00:00

removed rotmatrix as it did exactly the same as cspin

This commit is contained in:
Zeno Rogue 2019-08-09 23:59:32 +02:00
parent 9588dfcc50
commit 2cf6abb273
6 changed files with 34 additions and 43 deletions

View File

@ -32,10 +32,10 @@ transmatrix getOrientation() {
lasttick = curtick;
Uint8 *keystate = SDL_GetKeyState(NULL);
if(keystate[SDLK_LCTRL]) {
if(keystate['s']) Orient = Orient * rotmatrix(t, 2, 1);
if(keystate['w']) Orient = Orient * rotmatrix(t, 1, 2);
if(keystate['a']) Orient = Orient * rotmatrix(t, 2, 0);
if(keystate['d']) Orient = Orient * rotmatrix(t, 0, 2);
if(keystate['s']) Orient = Orient * cspin(2, 1, t);
if(keystate['w']) Orient = Orient * cspin(1, 2, t);
if(keystate['a']) Orient = Orient * cspin(2, 0, t);
if(keystate['d']) Orient = Orient * cspin(0, 2, t);
}
return Orient;
}

View File

@ -726,15 +726,6 @@ bool operator == (hyperpoint h1, hyperpoint h2) {
// rotation matrix in R^3
EX transmatrix rotmatrix(double rotation, int c0, int c1) {
transmatrix t = Id;
t[c0][c0] = cos(rotation);
t[c1][c1] = cos(rotation);
t[c0][c1] = sin(rotation);
t[c1][c0] = -sin(rotation);
return t;
}
EX hyperpoint mid3(hyperpoint h1, hyperpoint h2, hyperpoint h3) {
return mid(h1+h2+h3, h1+h2+h3);
}

View File

@ -175,9 +175,9 @@ transmatrix getOrientation() {
beta = EM_ASM_DOUBLE({ return rotation_beta; });
gamma = EM_ASM_DOUBLE({ return rotation_gamma; });
return
rotmatrix(alpha * degree, 0, 1) *
rotmatrix(beta * degree, 1, 2) *
rotmatrix(gamma * degree, 0, 2);
cspin(0, 1, alpha * degree) *
cspin(1, 2, beta * degree) *
cspin(0, 2, gamma * degree);
}
#endif

View File

@ -256,7 +256,7 @@ void make_twopoint(ld& x, ld& y) {
hyperpoint mobius(hyperpoint h, ld angle, ld scale = 1) {
h = perspective_to_space(h * scale, 1, gcSphere);
h = rotmatrix(angle * degree, 1, 2) * h;
h = cspin(1, 2, angle * degree) * h;
return space_to_perspective(h, 1) / scale;
}

40
rug.cpp
View File

@ -1554,7 +1554,7 @@ bool handlekeys(int sym, int uni) {
crystal::switch_z_coordinate();
else
#endif
apply_rotation(rotmatrix(M_PI, 0, 2));
apply_rotation(cspin(0, 2, M_PI));
return true;
}
else if(NUMBERKEY == '3') {
@ -1563,7 +1563,7 @@ bool handlekeys(int sym, int uni) {
crystal::flip_z();
else
#endif
apply_rotation(rotmatrix(M_PI/2, 0, 2));
apply_rotation(cspin(0, 2, M_PI/2));
return true;
}
#if CAP_CRYSTAL
@ -1581,12 +1581,12 @@ bool handlekeys(int sym, int uni) {
move_forward(-.1);
return true;
}
else if(sym == SDLK_HOME) { apply_rotation(rotmatrix(.1, 0, 1)); return true; }
else if(sym == SDLK_END) { apply_rotation(rotmatrix(.1, 1, 0)); return true; }
else if(sym == SDLK_DOWN) { apply_rotation(rotmatrix(.1, 2, 1)); return true; }
else if(sym == SDLK_UP) { apply_rotation(rotmatrix(.1, 1, 2)); return true; }
else if(sym == SDLK_LEFT) { apply_rotation(rotmatrix(.1, 2, 0)); return true; }
else if(sym == SDLK_RIGHT) { apply_rotation(rotmatrix(.1, 0, 2)); return true; }
else if(sym == SDLK_HOME) { apply_rotation(cspin(0, 1, .1)); return true; }
else if(sym == SDLK_END) { apply_rotation(cspin(1, 0, .1)); return true; }
else if(sym == SDLK_DOWN) { apply_rotation(cspin(2, 1, .1)); return true; }
else if(sym == SDLK_UP) { apply_rotation(cspin(1, 2, .1)); return true; }
else if(sym == SDLK_LEFT) { apply_rotation(cspin(2, 0, .1)); return true; }
else if(sym == SDLK_RIGHT) { apply_rotation(cspin(0, 2, .1)); return true; }
#endif
else return false;
}
@ -1659,13 +1659,13 @@ void actDraw() {
if(finger_center)
perform_finger();
else {
if(keystate[SDLK_HOME]) qm++, t = t * rotmatrix(alpha, 0, 1), protractor += alpha;
if(keystate[SDLK_END]) qm++, t = t * rotmatrix(alpha, 1, 0), protractor -= alpha;
if(keystate[SDLK_HOME]) qm++, t = t * cspin(0, 1, alpha), protractor += alpha;
if(keystate[SDLK_END]) qm++, t = t * cspin(1, 0, alpha), protractor -= alpha;
if(!keystate[SDLK_LSHIFT]) {
if(keystate[SDLK_DOWN]) qm++, t = t * rotmatrix(alpha, 2, 1), protractor += alpha;
if(keystate[SDLK_UP]) qm++, t = t * rotmatrix(alpha, 1, 2), protractor -= alpha;
if(keystate[SDLK_LEFT]) qm++, t = t * rotmatrix(alpha, 2, 0), protractor += alpha;
if(keystate[SDLK_RIGHT]) qm++, t = t * rotmatrix(alpha, 0, 2), protractor -= alpha;
if(keystate[SDLK_DOWN]) qm++, t = t * cspin(2, 1, alpha), protractor += alpha;
if(keystate[SDLK_UP]) qm++, t = t * cspin(1, 2, alpha), protractor -= alpha;
if(keystate[SDLK_LEFT]) qm++, t = t * cspin(2, 0, alpha), protractor += alpha;
if(keystate[SDLK_RIGHT]) qm++, t = t * cspin(0, 2, alpha), protractor -= alpha;
}
if(keystate[SDLK_PAGEDOWN]) push -= alpha;
if(keystate[SDLK_PAGEUP]) push += alpha;
@ -1698,13 +1698,13 @@ void actDraw() {
if(keystate[SDLK_HOME] && !in_crystal()) qm++, t = inverse(currentrot);
if(keystate[SDLK_END]) {
qm++;
if(in_crystal()) t = t * rotmatrix(alpha, 0, 1);
else t = currentrot * rotmatrix(alpha, 0, 1) * inverse(currentrot);
if(in_crystal()) t = t * cspin(0, 1, alpha);
else t = currentrot * cspin(0, 1, alpha) * inverse(currentrot);
}
if(keystate[SDLK_DOWN]) qm++, t = t * rotmatrix(alpha, 1, 2);
if(keystate[SDLK_UP]) qm++, t = t * rotmatrix(alpha, 2, 1);
if(keystate[SDLK_LEFT]) qm++, t = t * rotmatrix(alpha, 0, 2);
if(keystate[SDLK_RIGHT]) qm++, t = t * rotmatrix(alpha, 2, 0);
if(keystate[SDLK_DOWN]) qm++, t = t * cspin(1, 2, alpha);
if(keystate[SDLK_UP]) qm++, t = t * cspin(2, 1, alpha);
if(keystate[SDLK_LEFT]) qm++, t = t * cspin(0, 2, alpha);
if(keystate[SDLK_RIGHT]) qm++, t = t * cspin(2, 0, alpha);
if(keystate[SDLK_PAGEUP]) model_distance /= exp(alpha * ruggospeed);
if(keystate[SDLK_PAGEDOWN]) model_distance *= exp(alpha * ruggospeed);
}

View File

@ -669,12 +669,12 @@ EX void apply() {
#if CAP_RUG
if(rug::rugged) {
if(rug_rotation1) {
rug::apply_rotation(rotmatrix(rug_angle * degree, 1, 2));
rug::apply_rotation(rotmatrix(rug_rotation1 * 2 * M_PI * t / period, 0, 2));
rug::apply_rotation(rotmatrix(-rug_angle * degree, 1, 2));
rug::apply_rotation(cspin(1, 2, rug_angle * degree));
rug::apply_rotation(cspin(0, 2, rug_rotation1 * 2 * M_PI * t / period));
rug::apply_rotation(cspin(1, 2, -rug_angle * degree));
}
if(rug_rotation2) {
rug::apply_rotation(rug::currentrot * rotmatrix(rug_rotation2 * 2 * M_PI * t / period, 0, 1) * inverse(rug::currentrot));
rug::apply_rotation(rug::currentrot * cspin(0, 1, rug_rotation2 * 2 * M_PI * t / period) * inverse(rug::currentrot));
}
}
#endif
@ -1141,9 +1141,9 @@ void perspective() {
void rug() {
dynamicval<bool> b(rug::rugged, true);
rug::physics();
rug::apply_rotation(rotmatrix(ticks / 3000., 1, 2));
rug::apply_rotation(cspin(1, 2, ticks / 3000.));
gamescreen(2);
rug::apply_rotation(rotmatrix(-ticks / 3000., 1, 2));
rug::apply_rotation(cspin(1, 2, -ticks / 3000.));
}
#endif