mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2026-11-02 22:14:30 +00:00
better handling of precision errors in arcm and arb
This commit is contained in:
1 parent
5e87f08f54
commit
6c9f7e71e1
3 files changed
+20
-10
No files matched your search
@@ -1681,5 +1681,21 @@ EX bool clockwise(hyperpoint h1, hyperpoint h2) {
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user