mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-27 22:39:53 +00:00
more precise edge computation, using binary search
This commit is contained in:
parent
194e314069
commit
4a57ec002a
@ -82,15 +82,15 @@ struct trianglemaker {
|
|||||||
|
|
||||||
hyperpoint start = point31(0, 0, 0);
|
hyperpoint start = point31(0, 0, 0);
|
||||||
|
|
||||||
double lastz;
|
|
||||||
|
|
||||||
double lasta;
|
|
||||||
|
|
||||||
double ca;
|
double ca;
|
||||||
|
|
||||||
// compute how to scale this in Nil so that everything fits
|
// 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;
|
hyperpoint at = start;
|
||||||
for(int d=0; d<3; d++) {
|
for(int d=0; d<3; d++) {
|
||||||
for(int i=0; i<isteps; i++) {
|
for(int i=0; i<isteps; i++) {
|
||||||
@ -100,11 +100,11 @@ struct trianglemaker {
|
|||||||
|
|
||||||
println(hlog, "at = ", at, " for a = ", a, " sq = ", at[2] / a / a);
|
println(hlog, "at = ", at, " for a = ", a, " sq = ", at[2] / a / a);
|
||||||
if(at[2] > 0) {
|
if(at[2] > 0) {
|
||||||
ld z = at[2];
|
amax = a;
|
||||||
ca = lerp(lasta, a, ilerp(lastz, z, 0));
|
}
|
||||||
break;
|
else {
|
||||||
|
amin = a;
|
||||||
}
|
}
|
||||||
lastz = at[2]; lasta =a;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute the shift between the cubes
|
// compute the shift between the cubes
|
||||||
|
Loading…
Reference in New Issue
Block a user