intra:: binary x Z now connects to Solv/H3, fixes to product vertical

This commit is contained in:
Zeno Rogue 2021-10-08 01:30:35 +02:00
parent a04635111c
commit f97282099c
3 changed files with 62 additions and 28 deletions

View File

@ -48,10 +48,17 @@ hyperpoint portal_data::to_poco(hyperpoint h) const {
if(prod && kind == 1) {
auto dec = product_decompose(h);
h = dec.second;
h[0] /= h[2];
h[1] /= h[2];
h[2] = dec.first - d;
h[3] = 1;
if(bt::in()) {
h = PIU( deparabolic13(h) );
h[2] = dec.first - d;
h[3] = 1;
}
else {
h[0] /= h[2];
h[1] /= h[2];
h[2] = dec.first - d;
h[3] = 1;
}
if(d<0) h[2] = -h[2], h[0] = -h[0];
return h;
}
@ -90,6 +97,10 @@ hyperpoint portal_data::from_poco(hyperpoint h) const {
if(prod && kind == 1) {
ld xd = h[2];
if(d<0) xd = -xd, h[0] = -h[0];
if(bt::in()) {
h[2] = 0;
return PIU( parabolic13(h) ) * exp(d+xd);
}
h[2] = 1;
auto z = product_decompose(h).first;
return h * exp(d+xd-z);
@ -100,7 +111,7 @@ hyperpoint portal_data::from_poco(hyperpoint h) const {
h[1] = sin_auto(h0[0]);
h[2] = cos_auto(h0[0]) * cos_auto(h0[2]);
h[3] = 1;
return iT * h * exp(-h0[1]);
return iT * h * exp(h0[1]);
}
else if(hyperbolic && bt::in()) {
h[2] *= exp(-h[1]);
@ -123,15 +134,14 @@ EX portal_data make_portal(cellwalker cw, int spin) {
portal_data id;
id.scale = 1;
auto gg = geometry;
if(prod && cw.spin == cw.at->type - 1) {
id.kind = 1;
id.d = product_decompose(fac[0]).first;
id.v0 = C0 * exp(id.d);
}
else if(prod && cw.spin == cw.at->type - 2) {
if(prod && cw.spin >= cw.at->type - 2) {
id.kind = 1;
id.d = product_decompose(fac[0]).first;
id.v0 = C0 * exp(id.d);
if(bt::in()) {
fac.pop_back();
id.scale = log(2)/2;
}
}
else if(prod) {
id.kind = 0;
@ -139,7 +149,9 @@ EX portal_data make_portal(cellwalker cw, int spin) {
id.scale = cgi.plevel;
for(auto p: fac) id.v0 += p;
id.v0 /= sqrt(abs(intval(id.v0, Hypc)));
id.T = cpush(0, -hdist0(id.v0)) * spintox(id.v0);
hyperpoint h = fac[0];
h /= sqrt(abs(intval(h, Hypc)));
id.T = cspin(0, 1, -90*degree) * spintox(gpushxto0(id.v0) * h) * gpushxto0(id.v0);
for(int i=0; i<3; i++) id.T[3][i] = id.T[i][3] = i==3;
if(debugflags & DF_GEOM)
for(int a=0; a<4; a++) {

View File

@ -1011,7 +1011,7 @@ void raygen::emit_intra_portal(int gid1, int gid2) {
fmain += "mediump vec4 nposition;\n";
fmain += "if(pconnection.x != .5) {\n"; // kind != 0
if(1) {
string fn = in_h2xe() ? "to_poco_h2xr_h" : "to_poco_s2xr_s";
string fn = bt::in() ? "to_poco_h2xr_b" : in_h2xe() ? "to_poco_h2xr_h" : "to_poco_s2xr_s";
fmain +=
" nposition = position + tangent * xspeed * 1e-3;\n"
" position = "+fn+"(position);\n"
@ -1080,7 +1080,7 @@ void raygen::emit_intra_portal(int gid1, int gid2) {
fmain += "if(pconnection.z != .5) {\n"; // kind != 0
if(1) {
string sgn = in_h2xe() ? "-" : "+";
string fn = in_h2xe() ? "from_poco_h2xr_h" : "from_poco_s2xr_s";
string fn = bt::in() ? "from_poco_h2xr_b" : in_h2xe() ? "from_poco_h2xr_h" : "from_poco_s2xr_s";
fmain +=
" if(pconnection.w < .5) { position.z = -position.z; nposition.z = -nposition.z; nposition.x = -nposition.x; position.x = -position.x; }\n"
@ -1547,19 +1547,6 @@ void raygen::add_functions() {
" return res;\n"
" }\n\n");
add_if("deparabolic12",
"mediump vec4 deparabolic12(mediump vec4 h) {\n"
" h /= (1. + h.z);\n"
" h[0] -= 1.;\n"
" h /= h.x*h.x + h.y*h.y;\n"
" h[0] += .5;\n"
" mediump vec4 res;\n"
" res.x = (log(2.) + log(-h.x));\n"
" res.y = h.y * 2.;\n"
" res.w = 1.;\n"
" return res;\n"
" }\n\n");
add_if("enparabolic13",
"mediump vec4 enparabolic13(mediump vec4 h) {\n"
" mediump vec4 res;\n"
@ -1607,6 +1594,18 @@ void raygen::add_functions() {
" return pos;\n"
" }\n\n");
add_if("from_poco_h2xr_b",
"mediump vec4 from_poco_h2xr_b(mediump vec4 pos) {\n"
" return enparabolic12(pos);\n"
" }\n\n");
add_if("to_poco_h2xr_b",
"mediump vec4 to_poco_h2xr_b(mediump vec4 pos) {\n"
" pos /= sqrt(pos.z*pos.z-pos.x*pos.x-pos.y*pos.y);\n"
" pos = deparabolic12(pos);\n"
" return pos;\n"
" }\n\n");
add_if("from_poco_h2xr_e",
"mediump vec4 from_poco_h2xr_e(mediump vec4 pos) {\n"
" return vec4(sinh(pos[2]) * cosh(pos[0]), sinh(pos[0]), cosh(pos[0]) * cosh(pos[2]), 0);\n"
@ -1643,6 +1642,29 @@ void raygen::add_functions() {
" return vec4(x, 0, asin_clamp(pos[0] / cos(x)), 1);\n"
" }\n\n");
add_if("deparabolic12",
"mediump vec4 deparabolic12(mediump vec4 h) {\n"
" h /= (1. + h.z);\n"
" h[0] -= 1.;\n"
" h /= h.x*h.x + h.y*h.y;\n"
" h[0] += .5;\n"
" mediump vec4 res;\n"
" res.x = (log(2.) + log(-h.x));\n"
" res.y = h.y * 2.;\n"
" res.w = 1.;\n"
" return res;\n"
" }\n\n");
add_if("enparabolic12",
"mediump vec4 enparabolic12(mediump vec4 h) {\n"
" mediump vec4 res;\n"
" float diag = h.y*h.y /2.;\n"
" res.x = sinh(h.x) + diag * exp(-h.x);\n"
" res.y = h.y * exp(-h.x);\n"
" res.z = cosh(h.x) + diag * exp(-h.x);\n"
" return res;\n"
" }\n\n");
add_if("len_rotspace", "mediump float len_rotspace(vec4 h) { return 1. - h[3]; }\n");
add_if("len_h3", " mediump float len_h3(mediump vec4 x) { return x[3]; }\n");

View File

@ -17,7 +17,7 @@ EX hyperpoint final_coords(hyperpoint h) {
if(sn::in() || !bt::in())
return ultra_normalize(h);
#if CAP_BT
if(bt::in())
if(bt::in() && !prod)
return bt::bt_to_minkowski(h);
#endif
return h;