1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-28 02:50:34 +00:00

embeddings:: simplified and fixed euc_in_sl2

This commit is contained in:
Zeno Rogue 2023-01-27 10:17:54 +01:00
parent e4239a11a4
commit 56f5fee8dd
3 changed files with 10 additions and 28 deletions

View File

@ -500,21 +500,17 @@ struct emb_euc_in_product : emb_euclid_noniso {
struct emb_euc_in_sl2 : emb_euclid_noniso {
/** used in esl2_ita */
EX transmatrix esl2_zpush(ld z) { return cspin(2, 3, z) * cspin(0, 1, z); }
transmatrix esl2_zpush(ld z) { return cspin(2, 3, z) * cspin(0, 1, z); }
/** see esl2_ita; equal to esl2_ita * C0 */
EX hyperpoint esl2_ita0(hyperpoint h1) {
return esl2_zpush(h1[2]) * xpush(h1[0]) * ypush0(h1[1]);
hyperpoint intermediate_to_actual(hyperpoint i) override {
return esl2_zpush(i[2]) * xpush(i[0]) * ypush0(i[1]);
}
/** in embedded-in-sl2, convert from intermediate to actual coordinates */
EX transmatrix esl2_ita(hyperpoint h1) {
return esl2_zpush(h1[2]) * xpush(h1[0]) * ypush(h1[1]);
transmatrix intermediate_to_actual_translation(hyperpoint i) override {
return esl2_zpush(i[2]) * xpush(i[0]) * ypush(i[1]);
}
/** in embedded-in-sl2, convert from actual to intermediate coordinates */
EX hyperpoint esl2_ati(hyperpoint h) {
hyperpoint actual_to_intermediate(hyperpoint h) override {
ld a1 = (h[0] * h[3] - h[1] * h[2]) / (-h[2] * h[2] - h[1] * h[1] -h[0] * h[0] - h[3] * h[3]);
// a1 is S*sqrt(1+S*S) / (1+2*S*S), where S = sinh(-x) and C = cosh(-x); U is S*S
ld a = a1 * a1;
@ -532,20 +528,6 @@ struct emb_euc_in_sl2 : emb_euclid_noniso {
bool is_euc_in_sl2() override { return true; }
bool no_spin() override { return true; }
transmatrix get_lsti() override { return cspin90(2, 1); }
hyperpoint actual_to_intermediate(hyperpoint a) override { return esl2_ati(a); }
transmatrix intermediate_to_actual_translation(hyperpoint i) override { return esl2_zpush(i[2]) * xpush(i[0]) * ypush(i[1]); }
ld get_logical_z(hyperpoint a) override { return esl2_ati(a)[1]; }
hyperpoint orthogonal_move(const hyperpoint& a, ld z) override {
hyperpoint h1 = esl2_ati(a);
h1[1] += z;
return esl2_ita0(h1);
}
hyperpoint flatten(hyperpoint h) {
hyperpoint h1 = esl2_ati(h);
h1[1] = 0;
return esl2_ita0(h1);
}
};
/* for both seCylinderH and seCylinderE. Possibly actually works for CliffordTorus too */

View File

@ -3306,7 +3306,7 @@ EX void shift_v_by_vector(transmatrix& V, const hyperpoint H, eShiftMethod sm IS
V = iview_inverse(nisot::parallel_transport(view_inverse(V), -H));
return;
case smESL2: {
hyperpoint H1 = esl2_ita0(lp_iapply(-H));
hyperpoint H1 = cgi.emb->intermediate_to_actual(lp_iapply(-H));
transmatrix IV = view_inverse(V);
transmatrix rot = V * cgi.emb->map_relative_push(IV * C0);
transmatrix V1 = gpushxto0(H1) * gpushxto0(IV*C0);
@ -3376,7 +3376,7 @@ EX void shift_v_to(transmatrix& V, shiftpoint H, eShiftMethod sm IS(shift_method
case smProduct:
return shift_v_by_matrix(V, gpushxto0(unshift(H)), sm);
case smESL2:
return shift_v_by_vector(V, -lp_apply(esl2_ati(lp_iapply(unshift(H)))), sm);
return shift_v_by_vector(V, -lp_apply(cgi.emb->actual_to_intermediate(lp_iapply(unshift(H)))), sm);
case smLie:
return shift_v_by_vector(V, -lie_log(H), sm);
return;
@ -3398,7 +3398,7 @@ EX void shift_v_towards(transmatrix& V, shiftpoint H, ld l, eShiftMethod sm IS(s
case smEmbedded:
return shift_v_by_matrix(V, rspintox(unshift(H)) * xpush(-l) * spintox(unshift(H)), sm);
case smESL2:
return shift_v_by_vector(V, -lp_apply(tangent_length(esl2_ati(lp_iapply(unshift(H))), l)), sm);
return shift_v_by_vector(V, -lp_apply(tangent_length(cgi.emb->actual_to_intermediate(lp_iapply(unshift(H))), l)), sm);
case smLie:
return shift_v_by_vector(V, tangent_length(lie_log(H), -l), sm);
case smGeodesic:

View File

@ -73,7 +73,7 @@ pair<bool, hyperpoint> makeradar(shiftpoint h) {
if(d) h1 = h1 / (vid.radarrange + cgi.scalefactor/4);
}
else if(cgi.emb->is_euc_in_sl2()) {
h1 = cgi.emb->intermediate_to_logical * esl2_ati(unshift(h)); h1[1] = -h1[1];
h1 = cgi.emb->intermediate_to_logical * cgi.emb->actual_to_intermediate(unshift(h)); h1[1] = -h1[1];
d = hypot_d(2, h1);
if(d > vid.radarrange) return {false, h1};
if(d) h1 = h1 / (vid.radarrange + cgi.scalefactor/4);