From 041c7af98776a9614fecd3b1faaba69719e44368 Mon Sep 17 00:00:00 2001 From: ? Date: Wed, 27 Feb 2019 19:33:13 +0100 Subject: [PATCH] 3d:: *_d functions now consistently put d as the first argument --- hyper.h | 4 ++-- hyperpoint.cpp | 14 +++++++------- hypgraph.cpp | 24 ++++++++++++------------ polygons.cpp | 4 ++-- sphere.cpp | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/hyper.h b/hyper.h index 6624e26f..f40af805 100644 --- a/hyper.h +++ b/hyper.h @@ -3593,8 +3593,8 @@ bool model_needs_depth(); hyperpoint hpxy(ld x, ld y); hyperpoint hpxy3(ld x, ld y, ld z); -ld sqhypot_d(const hyperpoint& h, int d); -ld hypot_d(const hyperpoint& h, int d); +ld sqhypot_d(int d, const hyperpoint& h); +ld hypot_d(int d, const hyperpoint& h); transmatrix pushxto0(const hyperpoint& H); transmatrix rpushxto0(const hyperpoint& H); transmatrix spintox(const hyperpoint& H); diff --git a/hyperpoint.cpp b/hyperpoint.cpp index 0958c7a1..ea08069d 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -145,7 +145,7 @@ const hyperpoint Cx13 = hyperpoint(1,0,0,1.41421356237); // through the interior, not on the surface) // also used to verify whether a point h1 is on the hyperbolic plane by using Hypc for h2 -bool zero_d(hyperpoint h, int d) { +bool zero_d(int d, hyperpoint h) { for(int i=0; i= 1 ? 0 : mh[DIM] <= -1 ? M_PI : acos(mh[DIM]); diff --git a/hypgraph.cpp b/hypgraph.cpp index 23b51879..1cebe657 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -288,7 +288,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { conformal::apply_orientation(H[0], H[1]); H[1] += 1; - double rad = sqhypot_d(H, 2); + double rad = sqhypot_d(2, H); H /= -rad; H[1] += .5; @@ -318,7 +318,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { case gcHyperbolic: { ld zl = zlevel(H); ret = H / H[2]; - ret[2] = sqrt(1 - sqhypot_d(ret, 2)); + ret[2] = sqrt(1 - sqhypot_d(2, ret)); ret = ret * (1 + (zl - 1) * ret[2]); break; } @@ -356,7 +356,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { if(pmodel == mdHyperboloid) { ld& topz = conformal::top_z; if(H[2] > topz) { - ld scale = sqrt(topz*topz-1) / hypot_d(H, 2); + ld scale = sqrt(topz*topz-1) / hypot_d(2, H); H *= scale; H[2] = topz; } @@ -378,7 +378,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { ld zlev = find_zlev(H); H = space_to_perspective(H); H[2] = zlev; - ret = H / sqrt(1 + sqhypot_d(H, 3)); + ret = H / sqrt(1 + sqhypot_d(3, H)); break; } @@ -408,7 +408,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { } H = space_to_perspective(H); - ld r = hypot_d(H, 2); + ld r = hypot_d(2, H); ld c = H[0] / r; ld s = H[1] / r; ld& mt = conformal::model_transition; @@ -423,7 +423,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { ret = mobius(ret, vid.skiprope, 2); if(pmodel == mdJoukowskyInverted) { - ld r2 = sqhypot_d(ret, 2); + ld r2 = sqhypot_d(2, ret); ret[0] = ret[0] / r2; ret[1] = -ret[1] / r2; conformal::apply_orientation(ret[1], ret[0]); @@ -473,7 +473,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { H[0] -= .5; ld phi = atan2(H); - ld r = hypot_d(H, 2); + ld r = hypot_d(2, H); r = pow(r, 1 - mt); phi *= (1 - mt); @@ -510,7 +510,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { case mdEquidistant: case mdEquiarea: { ld zlev = find_zlev(H); - ld rad = hypot_d(H, 2); + ld rad = hypot_d(2, H); if(rad == 0) rad = 1; ld d = hdist0(H); ld df, zf; @@ -1062,7 +1062,7 @@ void centerpc(ld aspd) { hyperpoint H = tC0(cwtV); if(DIM == 2) H = ypush(-vid.yshift) * sphereflip * H; if(DIM == 3 && !shmup::on && vid.yshift) H = cpush(2, -vid.yshift) * H; - ld R = zero_d(H, DIM) ? 0 : hdist0(H); + ld R = zero_d(DIM, H) ? 0 : hdist0(H); if(R < 1e-9) { // either already centered or direction unknown /* if(playerfoundL && playerfoundR) { @@ -1247,7 +1247,7 @@ void circle_around_center(ld radius, color_t linecol, color_t fillcol, PPR prio) if(among(pmodel, mdDisk, mdEquiarea, mdEquidistant, mdFisheye) && !(pmodel == mdDisk && hyperbolic && vid.alpha <= -1) && vid.camera_angle == 0) { hyperpoint ret; applymodel(xpush0(radius), ret); - ld r = hypot_d(ret, 2); + ld r = hypot_d(2, ret); queuecircle(current_display->xcenter, current_display->ycenter, r * current_display->radius, linecol, prio, fillcol); return; } @@ -1343,7 +1343,7 @@ void queuestraight(hyperpoint X, int style, color_t lc, color_t fc, PPR p) { hyperpoint H; applymodel(X, H); H *= current_display->radius; - ld mul = hypot(vid.xres, vid.yres) / hypot_d(H, 2); + ld mul = hypot(vid.xres, vid.yres) / hypot_d(2, H); ld m = style == 1 ? -mul : -1; queuereset(mdUnchanged, p); @@ -1606,7 +1606,7 @@ bool do_draw(cell *c) { bool do_draw(cell *c, const transmatrix& T) { if(DIM == 3) { if(hyperbolic && T[DIM][DIM] > cosh(sightranges[geometry])) return false; - if(euclid && hypot_d(tC0(T), 3) > sightranges[geometry]) return false; + if(euclid && hypot_d(3, tC0(T)) > sightranges[geometry]) return false; setdist(c, 7, c); return true; } diff --git a/polygons.cpp b/polygons.cpp index 04dd3f3f..e78d247c 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -656,7 +656,7 @@ double scale_at(const transmatrix& T) { applymodel(tC0(T), h1); applymodel(T * xpush0(.01), h2); applymodel(T * ypush(.01) * C0, h3); - return sqrt(hypot_d(h2-h1, 2) * hypot_d(h3-h1, 2) / .0001); + return sqrt(hypot_d(2, h2-h1) * hypot_d(2, h3-h1) / .0001); } double linewidthat(const hyperpoint& h) { @@ -960,7 +960,7 @@ void dqi_poly::draw() { ld c1 = ah1[1], c2 = -ah2[1]; if(c1 < 0) c1 = -c1, c2 = -c2; hyperpoint h = ah1 * c1 + ah2 * c2; - h /= hypot_d(h, 3); + h /= hypot_d(3, h); if(h[2] < 0 && abs(h[0]) < sin(vid.twopoint_param)) cpha = 1-cpha, pha = 2; } if(cpha == 1) pha = 0; diff --git a/sphere.cpp b/sphere.cpp index debc0ea4..aaa9d5db 100644 --- a/sphere.cpp +++ b/sphere.cpp @@ -279,7 +279,7 @@ void gen600() { for(int i=0; i<120; i++) if(inedge[root][i]) adj0.push_back(i); using namespace hyperpoint_vec; - for(int i=0; i<6; i++) for(int j=i+1; j<12; j++) if(zero_d(vertices120[adj0[i]] + vertices120[adj0[j]], 3)) + for(int i=0; i<6; i++) for(int j=i+1; j<12; j++) if(zero_d(3, vertices120[adj0[i]] + vertices120[adj0[j]])) swap(adj0[j], adj0[i+6]); for(int i=0; i<120; i++) for(int j=0; j<120; j++)