mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-26 10:00:42 +00:00
fixed the coordinate system naming, and added a comment on these names
This commit is contained in:
parent
8dede9f8a0
commit
e4839a19b7
18
geometry.cpp
18
geometry.cpp
@ -201,16 +201,16 @@ struct geometry_information {
|
|||||||
int base_distlimit;
|
int base_distlimit;
|
||||||
|
|
||||||
/* convert the tangent space in logical coordinates to actual coordinates */
|
/* convert the tangent space in logical coordinates to actual coordinates */
|
||||||
transmatrix logical_to_actual;
|
transmatrix logical_to_intermediate;
|
||||||
|
|
||||||
/* convert the tangent space in actual coordinates to logical coordinates */
|
/* convert the tangent space in actual coordinates to logical coordinates */
|
||||||
transmatrix actual_to_logical;
|
transmatrix intermediate_to_logical;
|
||||||
|
|
||||||
/* convert the tangent space in logical coordinates to actual coordinates */
|
/* convert the tangent space in logical coordinates to actual coordinates */
|
||||||
transmatrix logical_to_actual_units;
|
transmatrix logical_scaled_to_intemediate;
|
||||||
|
|
||||||
/* convert the tangent space in actual coordinates to logical coordinates */
|
/* convert the tangent space in actual coordinates to logical coordinates */
|
||||||
transmatrix actual_to_logical_units;
|
transmatrix intermediate_to_logical_scaled;
|
||||||
|
|
||||||
/** size of the Sword (from Orb of the Sword), used in the shmup mode */
|
/** size of the Sword (from Orb of the Sword), used in the shmup mode */
|
||||||
ld sword_size;
|
ld sword_size;
|
||||||
@ -592,7 +592,7 @@ EX bool is_reg3_variation(eVariation var) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void geometry_information::prepare_lta() {
|
void geometry_information::prepare_lta() {
|
||||||
auto& lta = logical_to_actual;
|
auto& lta = logical_to_intermediate;
|
||||||
bool b = geom3::flipped;
|
bool b = geom3::flipped;
|
||||||
if(b) geom3::light_flip(false);
|
if(b) geom3::light_flip(false);
|
||||||
lta = Id;
|
lta = Id;
|
||||||
@ -600,15 +600,15 @@ void geometry_information::prepare_lta() {
|
|||||||
if(geom3::euc_vertical()) lta = cspin90(2, 1) * lta;
|
if(geom3::euc_vertical()) lta = cspin90(2, 1) * lta;
|
||||||
if(geom3::hyp_in_solnih()) lta = cspin90(0, 1) * cspin90(1, 2) * cspin90(0, 1) * lta;
|
if(geom3::hyp_in_solnih()) lta = cspin90(0, 1) * cspin90(1, 2) * cspin90(0, 1) * lta;
|
||||||
}
|
}
|
||||||
logical_to_actual_units = lta;
|
logical_scaled_to_intemediate = lta;
|
||||||
if(geom3::euc_in_noniso()) {
|
if(geom3::euc_in_noniso()) {
|
||||||
lta = Id;
|
lta = Id;
|
||||||
lta[0][0] *= geom3::euclid_embed_scale;
|
lta[0][0] *= geom3::euclid_embed_scale;
|
||||||
lta[1][1] *= geom3::euclid_embed_scale * geom3::euclid_embed_scale_y;
|
lta[1][1] *= geom3::euclid_embed_scale * geom3::euclid_embed_scale_y;
|
||||||
lta = logical_to_actual_units * cspin(0, 1, geom3::euclid_embed_rotate * degree) * lta;
|
lta = logical_scaled_to_intemediate * cspin(0, 1, geom3::euclid_embed_rotate * degree) * lta;
|
||||||
}
|
}
|
||||||
actual_to_logical = inverse(lta);
|
intermediate_to_logical = inverse(lta);
|
||||||
actual_to_logical_units = inverse(logical_to_actual_units);
|
intermediate_to_logical_scaled = inverse(logical_scaled_to_intemediate);
|
||||||
if(b) geom3::light_flip(true);
|
if(b) geom3::light_flip(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5096,13 +5096,13 @@ EX void make_actual_view() {
|
|||||||
transmatrix T = actual_view_transform * View;
|
transmatrix T = actual_view_transform * View;
|
||||||
ld z = -tC0(view_inverse(T)) [2];
|
ld z = -tC0(view_inverse(T)) [2];
|
||||||
transmatrix R = actual_view_transform;
|
transmatrix R = actual_view_transform;
|
||||||
R = cgi.logical_to_actual_units * R;
|
R = cgi.logical_scaled_to_intemediate * R;
|
||||||
if(R[1][2] || R[2][2])
|
if(R[1][2] || R[2][2])
|
||||||
R = cspin(1, 2, -atan2(R[1][2], R[2][2])) * R;
|
R = cspin(1, 2, -atan2(R[1][2], R[2][2])) * R;
|
||||||
if(R[0][2] || R[2][2])
|
if(R[0][2] || R[2][2])
|
||||||
R = cspin(0, 2, -atan2(R[0][2], R[2][2])) * R;
|
R = cspin(0, 2, -atan2(R[0][2], R[2][2])) * R;
|
||||||
if(geom3::hyp_in_solnih()) R = Id;
|
if(geom3::hyp_in_solnih()) R = Id;
|
||||||
R = cgi.actual_to_logical_units * R;
|
R = cgi.intermediate_to_logical_scaled * R;
|
||||||
current_display->radar_transform = inverse(R) * zpush(-z);
|
current_display->radar_transform = inverse(R) * zpush(-z);
|
||||||
}
|
}
|
||||||
else if(gproduct) {
|
else if(gproduct) {
|
||||||
|
@ -716,7 +716,7 @@ EX transmatrix spin(ld alpha) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EX transmatrix unswap_spin(transmatrix T) {
|
EX transmatrix unswap_spin(transmatrix T) {
|
||||||
return cgi.actual_to_logical_units * T * cgi.logical_to_actual_units;
|
return cgi.intermediate_to_logical_scaled * T * cgi.logical_scaled_to_intemediate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** rotate by 90 degrees in the XY plane */
|
/** rotate by 90 degrees in the XY plane */
|
||||||
@ -1000,7 +1000,7 @@ EX void swapmatrix(transmatrix& T) {
|
|||||||
}
|
}
|
||||||
else if(geom3::euc_in_nil()) {
|
else if(geom3::euc_in_nil()) {
|
||||||
if(!geom3::flipped) {
|
if(!geom3::flipped) {
|
||||||
hyperpoint h1 = cgi.logical_to_actual * get_column(T, 2);
|
hyperpoint h1 = cgi.logical_to_intermediate * get_column(T, 2);
|
||||||
// rotations are illegal anyway...
|
// rotations are illegal anyway...
|
||||||
T = eupush(hyperpoint(h1[0], 0, h1[2], 1));
|
T = eupush(hyperpoint(h1[0], 0, h1[2], 1));
|
||||||
return;
|
return;
|
||||||
@ -1008,19 +1008,19 @@ EX void swapmatrix(transmatrix& T) {
|
|||||||
}
|
}
|
||||||
else if(geom3::euc_in_solnih()) {
|
else if(geom3::euc_in_solnih()) {
|
||||||
if(!geom3::flipped) {
|
if(!geom3::flipped) {
|
||||||
hyperpoint h1 = cgi.logical_to_actual * get_column(T, 2);
|
hyperpoint h1 = cgi.logical_to_intermediate * get_column(T, 2);
|
||||||
// rotations are illegal anyway...
|
// rotations are illegal anyway...
|
||||||
T = eupush(hyperpoint(h1[0], h1[1], 0, 1));
|
T = eupush(hyperpoint(h1[0], h1[1], 0, 1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(geom3::euc_in_product()) {
|
else if(geom3::euc_in_product()) {
|
||||||
hyperpoint h1 = cgi.logical_to_actual * get_column(T, 2);
|
hyperpoint h1 = cgi.logical_to_intermediate * get_column(T, 2);
|
||||||
T = xpush(h1[0]) * zpush(h1[2]);
|
T = xpush(h1[0]) * zpush(h1[2]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(geom3::euc_in_sl2() && !geom3::flipped) {
|
else if(geom3::euc_in_sl2() && !geom3::flipped) {
|
||||||
hyperpoint h1 = cgi.logical_to_actual * get_column(T, 2); h1[1] = 0;
|
hyperpoint h1 = cgi.logical_to_intermediate * get_column(T, 2); h1[1] = 0;
|
||||||
T = esl2_ita(h1);
|
T = esl2_ita(h1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1028,7 +1028,7 @@ EX void swapmatrix(transmatrix& T) {
|
|||||||
/* just do nothing */
|
/* just do nothing */
|
||||||
}
|
}
|
||||||
else if(geom3::euc_in_sph()) {
|
else if(geom3::euc_in_sph()) {
|
||||||
hyperpoint h1 = cgi.logical_to_actual * get_column(T, 2);
|
hyperpoint h1 = cgi.logical_to_intermediate * get_column(T, 2);
|
||||||
T = cspin(0, 2, h1[0]) * cspin(1, 3, h1[1]);
|
T = cspin(0, 2, h1[0]) * cspin(1, 3, h1[1]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -1046,25 +1046,25 @@ EX void swapmatrix(transmatrix& T) {
|
|||||||
/** Just like swapmatrix but for hyperpoints. */
|
/** Just like swapmatrix but for hyperpoints. */
|
||||||
EX void swapmatrix(hyperpoint& h) {
|
EX void swapmatrix(hyperpoint& h) {
|
||||||
if(geom3::euc_in_product()) {
|
if(geom3::euc_in_product()) {
|
||||||
h = cgi.logical_to_actual * h;
|
h = cgi.logical_to_intermediate * h;
|
||||||
h = xpush(h[0]) * zpush(h[2]) * C0;
|
h = xpush(h[0]) * zpush(h[2]) * C0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(geom3::in_product()) return;
|
if(geom3::in_product()) return;
|
||||||
if(geom3::sph_in_euc()) { h[3] = 1; return; }
|
if(geom3::sph_in_euc()) { h[3] = 1; return; }
|
||||||
if(geom3::sph_in_hyp()) { h[0] *= sinh(1); h[1] *= sinh(1); h[2] *= sinh(1); h[3] = cosh(1); return; }
|
if(geom3::sph_in_hyp()) { h[0] *= sinh(1); h[1] *= sinh(1); h[2] *= sinh(1); h[3] = cosh(1); return; }
|
||||||
if(geom3::euc_in_nil()) { h = cgi.logical_to_actual * h; h[3] = 1; h[1] = 0; return; }
|
if(geom3::euc_in_nil()) { h = cgi.logical_to_intermediate * h; h[3] = 1; h[1] = 0; return; }
|
||||||
if(geom3::euc_in_sl2()) {
|
if(geom3::euc_in_sl2()) {
|
||||||
hyperpoint h1 = cgi.logical_to_actual * h; h1[1] = 0;
|
hyperpoint h1 = cgi.logical_to_intermediate * h; h1[1] = 0;
|
||||||
h = esl2_ita0(h1);
|
h = esl2_ita0(h1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(geom3::euc_in_sph()) {
|
if(geom3::euc_in_sph()) {
|
||||||
h = cgi.logical_to_actual * h;
|
h = cgi.logical_to_intermediate * h;
|
||||||
h = cspin(0, 2, h[0]) * cspin(1, 3, h[1]) * lzpush(1) * C0;
|
h = cspin(0, 2, h[0]) * cspin(1, 3, h[1]) * lzpush(1) * C0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(geom3::euc_in_solnih()) { h = cgi.logical_to_actual * h; h[3] = 1; h[2] = 0; return; }
|
if(geom3::euc_in_solnih()) { h = cgi.logical_to_intermediate * h; h[3] = 1; h[2] = 0; return; }
|
||||||
if(geom3::hyp_in_solnih()) {
|
if(geom3::hyp_in_solnih()) {
|
||||||
// copied from deparabolic13
|
// copied from deparabolic13
|
||||||
h /= (1 + h[2]);
|
h /= (1 + h[2]);
|
||||||
|
@ -2036,7 +2036,7 @@ EX void adjust_eye(transmatrix& T, cell *c, ld sign) {
|
|||||||
|
|
||||||
/** achieve top-down perspective */
|
/** achieve top-down perspective */
|
||||||
EX transmatrix default_spin() {
|
EX transmatrix default_spin() {
|
||||||
return cspin90(0, 1) * cgi.actual_to_logical_units;
|
return cspin90(0, 1) * cgi.intermediate_to_logical_scaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX void centerpc(ld aspd) {
|
EX void centerpc(ld aspd) {
|
||||||
@ -2239,7 +2239,7 @@ EX void resetview() {
|
|||||||
|
|
||||||
if(WDIM == 2) vo = spin(M_PI + vid.fixed_facing_dir * degree) * vo;
|
if(WDIM == 2) vo = spin(M_PI + vid.fixed_facing_dir * degree) * vo;
|
||||||
if(WDIM == 3) vo = cspin90(0, 2) * vo;
|
if(WDIM == 3) vo = cspin90(0, 2) * vo;
|
||||||
vo = cgi.actual_to_logical_units * vo;
|
vo = cgi.intermediate_to_logical_scaled * vo;
|
||||||
if(embedded_plane) vo = cspin90(1, 2) * vo;
|
if(embedded_plane) vo = cspin90(1, 2) * vo;
|
||||||
if(embedded_plane && vid.wall_height < 0) vo = cspin180(0, 1) * vo;
|
if(embedded_plane && vid.wall_height < 0) vo = cspin180(0, 1) * vo;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user