diff --git a/basegraph.cpp b/basegraph.cpp index 4cfd3e9e..6664c88d 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -158,7 +158,7 @@ bool cameraangle_on; void setcameraangle(bool b) { if(cameraangle_on != b) { cameraangle_on = b; - ld cam = vid.camera_angle * M_PI / 180; + ld cam = vid.camera_angle * degree; GLfloat cc = cos(cam); GLfloat ss = sin(cam * (b?1:-1)); diff --git a/config.cpp b/config.cpp index fed5c1a6..6c5e15e2 100644 --- a/config.cpp +++ b/config.cpp @@ -1071,7 +1071,7 @@ string explain3D(ld *param) { "the center of your vision and a faraway location is 1/cosh(c) = %4).", fts3(camera), fts3(depth), - fts3(atan(1/cosh(camera))*2*180/M_PI), + fts3(atan(1/cosh(camera))*2/degree), fts3(1/cosh(camera))); if(param == &depth) return diff --git a/conformal.cpp b/conformal.cpp index 68ba4d63..6c36dfdc 100644 --- a/conformal.cpp +++ b/conformal.cpp @@ -374,7 +374,7 @@ namespace conformal { hyperpoint next = calc_relative_matrix(v[ph+1]->base, v[ph]->base, C0) * v[ph+1]->at * C0; - View = spin(M_PI/180 * rotation) * xpush(-(phase-ph) * hdist(now, next)) * View; + View = spin(rotation * degree) * xpush(-(phase-ph) * hdist(now, next)) * View; playermoved = false; centerover.at = v[ph]->base; compute_graphical_distance(); @@ -394,10 +394,10 @@ namespace conformal { } void configure() { - ld ball = -vid.ballangle * M_PI / 180; + ld ball = -vid.ballangle * degree; cos_ball = cos(ball), sin_ball = sin(ball); - ocos = cos(model_orientation * M_PI / 180); - osin = sin(model_orientation * M_PI / 180); + ocos = cos(model_orientation * degree); + osin = sin(model_orientation * degree); model_straight = (ocos > 1 - 1e-9); if(conformal::on) conformal::apply(); } @@ -741,7 +741,7 @@ namespace conformal { // cos(phi) * cos(phi) = 1/K if(sphere && vid.stretch >= 1) { ld phi = acos(sqrt(1/vid.stretch)); - dialog::addInfo(XLAT("The current value makes the map conformal at the latitude of %1 (%2°).", fts(phi), fts(phi * 180 / M_PI))); + dialog::addInfo(XLAT("The current value makes the map conformal at the latitude of %1 (%2°).", fts(phi), fts(phi / degree))); } else if(hyperbolic && abs(vid.stretch) <= 1 && abs(vid.stretch) >= 1e-9) { ld phi = acosh(abs(sqrt(1/vid.stretch))); diff --git a/graph.cpp b/graph.cpp index fb7a9c9a..8be319a0 100644 --- a/graph.cpp +++ b/graph.cpp @@ -4891,7 +4891,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) { downspin = atan2(VC0[1], VC0[0]); downspin -= M_PI/2; if(rev) downspin += M_PI; - downspin += M_PI/180 * conformal::rotation; + downspin += conformal::rotation * degree; while(downspin < -M_PI) downspin += 2*M_PI; while(downspin > +M_PI) downspin -= 2*M_PI; downspin = downspin * min(spd, (double)1); @@ -5487,7 +5487,7 @@ void calcparam() { vid.xcenter += vid.scrsize * vid.xposition; vid.ycenter += vid.scrsize * vid.yposition; - stereo::tanfov = tan(stereo::fov * M_PI / 360); + stereo::tanfov = tan(stereo::fov * degree / 2); if(pmodel) stereo::scrdist = vid.xres / 2 / stereo::tanfov; diff --git a/hyper.h b/hyper.h index 076db16e..c7726974 100644 --- a/hyper.h +++ b/hyper.h @@ -4326,5 +4326,7 @@ dqi_poly& queuecurve(color_t linecol, color_t fillcol, PPR prio); bool haveaura(); string parser_help(); + +static const ld degree = M_PI / 180; } diff --git a/hyperweb.cpp b/hyperweb.cpp index 772dc63b..c5612931 100644 --- a/hyperweb.cpp +++ b/hyperweb.cpp @@ -158,9 +158,9 @@ transmatrix getOrientation() { beta = EM_ASM_DOUBLE({ return rotation_beta; }); gamma = EM_ASM_DOUBLE({ return rotation_gamma; }); return - rotmatrix(alpha * M_PI / 180, 0, 1) * - rotmatrix(beta * M_PI / 180, 1, 2) * - rotmatrix(gamma * M_PI / 180, 0, 2); + rotmatrix(alpha * degree, 0, 1) * + rotmatrix(beta * degree, 1, 2) * + rotmatrix(gamma * degree, 0, 2); } #endif diff --git a/hypgraph.cpp b/hypgraph.cpp index 4049b895..9093e0d5 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -13,7 +13,7 @@ void ghcheck(hyperpoint &ret, const hyperpoint &H) { } void camrotate(ld& hx, ld& hy) { - ld cam = vid.camera_angle * M_PI / 180; + ld cam = vid.camera_angle * degree; GLfloat cc = cos(cam); GLfloat ss = sin(cam); ld ux = hx, uy = hy * cc + ss, uz = cc - ss * hy; @@ -221,7 +221,7 @@ void make_twopoint(ld& x, ld& y) { hyperpoint mobius(hyperpoint h, ld angle, ld scale = 1) { using namespace hyperpoint_vec; h = perspective_to_space(h * scale, 1, gcSphere); - h = rotmatrix(angle * M_PI / 180, 1, 2) * h; + h = rotmatrix(angle * degree, 1, 2) * h; return space_to_perspective(h, 1) / scale; } @@ -253,7 +253,7 @@ void applymodel(hyperpoint H, hyperpoint& ret) { else { ld tx = H[0]; ld ty = H[1]; - ld cam = vid.camera_angle * M_PI / 180; + ld cam = vid.camera_angle * degree; GLfloat cc = cos(cam); GLfloat ss = sin(cam); ld ux = tx, uy = ty * cc - ss * tz, uz = tz * cc + ss * ty; @@ -1134,7 +1134,7 @@ void circle_around_center(ld radius, color_t linecol, color_t fillcol, PPR prio) queuecircle(vid.xcenter, vid.ycenter, r * vid.radius, linecol, prio, fillcol); return; } - for(int i=0; i<360; i++) curvepoint(xspinpush0(i * 2 * M_PI / 360, 10)); + for(int i=0; i<=360; i++) curvepoint(xspinpush0(i * degree, 10)); auto& c = queuecurve(linecol, fillcol, prio); if(pmodel == mdDisk && hyperbolic && vid.alpha <= -1) c.flags |= POLY_FORCE_INVERTED; @@ -1148,7 +1148,7 @@ void draw_model_elements() { circle_around_center(M_PI/2, ringcolor, 0, PPR::CIRCLE); if(pmodel == mdTwoPoint) { - ld a = -conformal::model_orientation * M_PI / 180; + ld a = -conformal::model_orientation * degree; queuechr(xspinpush0(a, +vid.twopoint_param), vid.xres / 100, 'X', ringcolor >> 8); queuechr(xspinpush0(a, -vid.twopoint_param), vid.xres / 100, 'X', ringcolor >> 8); } diff --git a/mapeditor.cpp b/mapeditor.cpp index f5c47b70..95e9946c 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -993,7 +993,7 @@ namespace mapeditor { // at H1: (rh2 - a1 - M_PI) // at H2: (a2+M_PI - rh1) // total: rh2 - rh1 - // ld z = 180 / M_PI; + // ld z = degree; ld x = b2 - b1 + M_PI; while(x > M_PI) x -= 2 * M_PI; while(x < -M_PI) x += 2 * M_PI; @@ -1145,7 +1145,7 @@ namespace mapeditor { displayfr(vid.xres-8, vid.yres-8-fs*5, 2, vid.fsize, XLAT("y: %1", fts4(mh[1])), 0xC0C0C0, 16); displayfr(vid.xres-8, vid.yres-8-fs*4, 2, vid.fsize, XLAT("z: %1", fts4(mh[2])), 0xC0C0C0, 16); displayfr(vid.xres-8, vid.yres-8-fs*2, 2, vid.fsize, XLAT("r: %1", fts4(hdist0(mh))), 0xC0C0C0, 16); - displayfr(vid.xres-8, vid.yres-8-fs, 2, vid.fsize, XLAT("ϕ: %1°", fts4(-atan2(mh[1], mh[0]) * 360 / 2 / M_PI)), 0xC0C0C0, 16); + displayfr(vid.xres-8, vid.yres-8-fs, 2, vid.fsize, XLAT("ϕ: %1°", fts4(-atan2(mh[1], mh[0]) / degree)), 0xC0C0C0, 16); } if(us) { diff --git a/polygons.cpp b/polygons.cpp index 2f15fef5..6b2c0b0e 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -1050,7 +1050,7 @@ void dqi_poly::draw() { // we should fill the other side ld h = atan2(glcoords[0][0], glcoords[0][1]); for(int i=0; i<=360; i++) { - ld a = i * M_PI / 180 + h; + ld a = i * degree + h; glcoords.push_back(make_array(vid.radius * sin(a), vid.radius * vid.stretch * cos(a), stereo::scrdist)); } poly_flags ^= POLY_INVERSE; diff --git a/rogueviz-graph.cpp b/rogueviz-graph.cpp index 329ca132..efd80125 100644 --- a/rogueviz-graph.cpp +++ b/rogueviz-graph.cpp @@ -170,7 +170,7 @@ void run_snub(int v, int w) { hyperpoint f1 = facingdir(hts); ld scalar = (f|f1); - ld alpha = (M_PI - acos(scalar)) * 180 / M_PI; + ld alpha = (M_PI - acos(scalar)) / degree; sideangles.emplace_back(alpha, T); } } diff --git a/rogueviz-pentagonal.cpp b/rogueviz-pentagonal.cpp index b76d0252..3affa128 100644 --- a/rogueviz-pentagonal.cpp +++ b/rogueviz-pentagonal.cpp @@ -164,7 +164,7 @@ void run_snub(int v, int w) { hyperpoint f1 = facingdir(hts); ld scalar = (f|f1); - ld alpha = (M_PI - acos(scalar)) * 180 / M_PI; + ld alpha = (M_PI - acos(scalar)) / degree; sideangles.emplace_back(alpha, T); } } diff --git a/rogueviz.cpp b/rogueviz.cpp index a97a4199..5e77ef0d 100644 --- a/rogueviz.cpp +++ b/rogueviz.cpp @@ -356,7 +356,7 @@ namespace anygraph { coords.push_back(make_pair(r, alpha)); if(err < 2) { printf("Error: incorrect format of r/alpha\n"); exit(1); } - transmatrix h = spin(alpha * 2 * M_PI / 360) * xpush(r); + transmatrix h = spin(alpha * degree) * xpush(r); createViz(id, currentmap->gamestart(), h); }