From dd01cd9af4d90c560f7acdafab38b1016f81ae3d Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 5 Jan 2023 16:12:23 +0100 Subject: [PATCH] auto-configure Clifford Torus embedding --- geometry.cpp | 15 +++++++++++++++ rug.cpp | 8 +++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/geometry.cpp b/geometry.cpp index a6294c03..c22963fc 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -1400,6 +1400,7 @@ EX void switch_always3() { vid.wall_height *= -1; } } + if(spatial_embedding == seCliffordTorus) configure_clifford_torus(); } else { vid.always3 = false; @@ -1418,6 +1419,20 @@ EX void switch_always3() { #endif } + EX void configure_clifford_torus() { + rug::clifford_torus ct; + + euclid_embed_scale = TAU / hypot_d(2, ct.xh); + euclid_embed_scale_y = TAU / hypot_d(2, ct.yh) / euclid_embed_scale; + euclid_embed_rotate = atan2(ct.xh[1], ct.xh[0]) / degree; + + ld alpha = atan2(ct.xfactor, ct.yfactor); + + vid.depth = alpha - 1; + vid.wall_height = min(1 / euclid_embed_scale_mean(), (90._deg - alpha) * 0.9); + vid.eye = vid.wall_height / 2 - vid.depth; + } + EX } EX geometry_information *cgip; diff --git a/rug.cpp b/rug.cpp index 1b5b8914..7e167f2f 100644 --- a/rug.cpp +++ b/rug.cpp @@ -395,8 +395,14 @@ clifford_torus::clifford_torus() { auto p1 = to_loc(euc::eu.user_axes[0]); auto p2 = to_loc(euc::eu.user_axes[1]); + bool f = embedded_plane; + if(f) geom3::light_flip(true); xh = euc::eumove(p1)*C0-C0; yh = euc::eumove(p2)*C0-C0; + if(f) geom3::light_flip(false); + xh[2] = xh[3] = yh[2] = yh[3] = 0; + dynamicval g(geometry, gCubeTiling); + if(nonorientable) yh *= 2; flipped = false; // sqhypot_d(2, xh) < sqhypot_d(2, yh); @@ -409,7 +415,7 @@ clifford_torus::clifford_torus() { yfactor = sqrt(1/(1+factor2)); xfactor = factor * yfactor; - T = build_matrix(xh, yh, C0, C03); + T = build_matrix(xh, yh, C02, C03); iT = inverse(T); }