From 4a57ec002a8aa10efc699509f22a1e78ce35bfc5 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 1 May 2020 11:34:17 +0200 Subject: [PATCH] more precise edge computation, using binary search --- rogueviz/triangle.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rogueviz/triangle.cpp b/rogueviz/triangle.cpp index eec71383..c3d57c63 100644 --- a/rogueviz/triangle.cpp +++ b/rogueviz/triangle.cpp @@ -82,15 +82,15 @@ struct trianglemaker { hyperpoint start = point31(0, 0, 0); - double lastz; - - double lasta; - double ca; // compute how to scale this in Nil so that everything fits - for(ld a = 1e-5;; a+=1e-5) { + ld amin = 0, amax = 1; + + for(int it=0; it<100; it++) { + ld a = (amin + amax) / 2; + ca = a; hyperpoint at = start; for(int d=0; d<3; d++) { for(int i=0; i