mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-10-31 19:36:16 +00:00
better handling of precision errors in arcm and arb
This commit is contained in:
parent
5e87f08f54
commit
6c9f7e71e1
@ -930,15 +930,9 @@ struct hrmap_arbi : hrmap {
|
|||||||
alt = (heptagon*) s;
|
alt = (heptagon*) s;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& p2: altmap[alt]) if(id_of(p2.first) == co.sid && hdist(tC0(p2.second), tC0(T)) < 1e-2) {
|
for(auto& p2: altmap[alt]) if(id_of(p2.first) == co.sid && same_point_may_warn(tC0(p2.second), tC0(T))) {
|
||||||
for(int oth=0; oth < p2.first->type; oth++) {
|
for(int oth=0; oth < p2.first->type; oth++) {
|
||||||
ld err = hdist(p2.second * xsh.vertices[oth], T * xsh.vertices[co.eid]);
|
if(same_point_may_warn(p2.second * xsh.vertices[oth], T * xsh.vertices[co.eid])) {
|
||||||
if(err < 1e-2) {
|
|
||||||
static ld max_err = 0;
|
|
||||||
if(err > max_err) {
|
|
||||||
println(hlog, "err = ", err);
|
|
||||||
max_err = err;
|
|
||||||
}
|
|
||||||
h->c.connect(d, p2.first, oth%p2.first->type, co.mirror);
|
h->c.connect(d, p2.first, oth%p2.first->type, co.mirror);
|
||||||
return p2.first;
|
return p2.first;
|
||||||
}
|
}
|
||||||
|
@ -649,14 +649,14 @@ struct hrmap_archimedean : hrmap {
|
|||||||
|
|
||||||
DEBB(DF_GEOM, ("look for: ", alt, " / ", T * C0));
|
DEBB(DF_GEOM, ("look for: ", alt, " / ", T * C0));
|
||||||
|
|
||||||
for(auto& p2: altmap[alt]) if(intval(p2.second * C0, T * C0) < 1e-4) {
|
for(auto& p2: altmap[alt]) if(same_point_may_warn(p2.second * C0, T * C0)) {
|
||||||
DEBB(DF_GEOM, ("cell found: ", p2.first));
|
DEBB(DF_GEOM, ("cell found: ", p2.first));
|
||||||
for(int d2=0; d2<p2.first->degree(); d2++) {
|
for(int d2=0; d2<p2.first->degree(); d2++) {
|
||||||
heptspin hs(p2.first, d2);
|
heptspin hs(p2.first, d2);
|
||||||
auto& t2 = current.get_triangle(p2.first, d2);
|
auto& t2 = current.get_triangle(p2.first, d2);
|
||||||
transmatrix T1 = T * spin(M_PI + t2.first);
|
transmatrix T1 = T * spin(M_PI + t2.first);
|
||||||
DEBB(DF_GEOM, ("compare: ", T1 * xpush0(1), ":: ", p2.second * xpush0(1)));
|
DEBB(DF_GEOM, ("compare: ", T1 * xpush0(1), ":: ", p2.second * xpush0(1)));
|
||||||
if(intval(T1 * xpush0(1), p2.second * xpush0(1)) < 1e-4) {
|
if(same_point_may_warn(T1 * xpush0(1), p2.second * xpush0(1))) {
|
||||||
|
|
||||||
// T1 = p2.second
|
// T1 = p2.second
|
||||||
// T * spin(pi+t2.first) == p2.second
|
// T * spin(pi+t2.first) == p2.second
|
||||||
|
@ -1681,5 +1681,21 @@ EX bool clockwise(hyperpoint h1, hyperpoint h2) {
|
|||||||
return h1[0] * h2[1] > h1[1] * h2[0];
|
return h1[0] * h2[1] > h1[1] * h2[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX ld worst_precision_error;
|
||||||
|
|
||||||
|
#if HDR
|
||||||
|
struct hr_precision_error : hr_exception { hr_precision_error() : hr_exception("precision error") {} };
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/** check if a and b are the same, testing for equality. Throw an exception or warning if not sure */
|
||||||
|
EX bool same_point_may_warn(hyperpoint a, hyperpoint b) {
|
||||||
|
ld d = hdist(a, b);
|
||||||
|
if(d > 1e-2) return false;
|
||||||
|
if(d > 1e-3) throw hr_precision_error();
|
||||||
|
if(d > 1e-6 && worst_precision_error <= 1e-6)
|
||||||
|
addMessage("warning: precision errors are building up!");
|
||||||
|
if(d > worst_precision_error) worst_precision_error = d;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user