diff --git a/3d-models.cpp b/3d-models.cpp index 1917f6eb..86b0af10 100644 --- a/3d-models.cpp +++ b/3d-models.cpp @@ -606,7 +606,7 @@ void geometry_information::animate_bird(hpcshape& orig, hpcshape_animated& anima for(int i=0; i<=WINGS; i++) { auto& tgt = animated[i]; clone_shape(orig, tgt); - ld alpha = cos(180. * degree * i / WINGS) * 30 * degree; + ld alpha = cos(M_PI * i / WINGS) * 30 * degree; for(int i=tgt.s; i body) { ld off = hpc[i][1] > 0 ? body : -body; @@ -787,17 +787,17 @@ void geometry_information::shift_last_straight(ld z) { EX void queueball(const shiftmatrix& V, ld rad, color_t col, eItem what) { if(what == itOrbSpeed) { - shiftmatrix V1 = V * cspin(1, 2, M_PI/2); + shiftmatrix V1 = V * cspin90(1, 2); ld tt = ptick(100); for(int t=0; t<5; t++) { for(int a=-50; a<50; a++) - curvepoint(cspin(0, 2, a * M_PI/100.) * cspin(0, 1, t * 72 * degree + tt + a*2*M_PI/50.) * xpush0(rad)); + curvepoint(cspin(0, 2, a * M_PI/100.) * cspin(0, 1, t * 72._deg + tt + a*TAU/50.) * xpush0(rad)); queuecurve(V1, col, 0, PPR::LINE); } return; } ld z = 63.43 * degree; - shiftmatrix V1 = V * cspin(0, 2, M_PI/2); + shiftmatrix V1 = V * cspin90(0, 2); if(what == itOrbShield) V1 = V * cspin(0, 1, ptick(500)); if(what == itOrbFlash) V1 = V * cspin(0, 1, ptick(1500)); if(what == itOrbShield) V1 = V * cspin(1, 2, ptick(1000)); @@ -821,7 +821,7 @@ EX void queueball(const shiftmatrix& V, ld rad, color_t col, eItem what) { line(a, c); line(a, d); line(d, c); - line(c, spin(M_PI)); + line(c, spin180()); } } @@ -1256,7 +1256,7 @@ hpcshape& geometry_information::generate_pipe(ld length, ld width, ePipeEnd endt const int MAX_R = 20; auto at = [&] (ld i, ld a, ld z = 1, ld s = 1) { a += 0.5; - ld alpha = 360 * degree * a / MAX_R; + ld alpha = TAU * a / MAX_R; hpcpush(xpush(i * length / MAX_X) * cspin(1, 2, alpha) * ypush0(width*z)); #if CAP_GL if(floor_textures) utt.tvertices.push_back(glhr::makevertex(0, pers ? 0.549 - s * 0.45 * sin(alpha) : 0.999, 0)); @@ -1282,10 +1282,10 @@ hpcshape& geometry_information::generate_pipe(ld length, ld width, ePipeEnd endt if(endtype == ePipeEnd::ball) for(int a=0; a 360 * degree) a -= 360 * degree; + while(a < 0) a += TAU; + while(a > TAU) a -= TAU; total += a; anglelist.push_back(a); qty++; @@ -622,9 +622,9 @@ EX bool compute_vertex_valence_flat(arb::arbi_tiling& ac) { at = ac.shapes[at.sid].connections[at.eid]; } - while(total < 360*degree - 1e-6); + while(total < TAU - 1e-6); if(total == 0) qty = OINF; - if(total > 360*degree + 1e-6) throw hr_parse_exception("improper total in compute_stats"); + if(total > TAU + 1e-6) throw hr_parse_exception("improper total in compute_stats"); if(at.sid != i) throw hr_parse_exception("ended at wrong type determining vertex_valence"); if((at.eid - k) % ac.shapes[i].cycle_length) { reduce_gcd(ac.shapes[i].cycle_length, at.eid - k); @@ -1997,8 +1997,7 @@ EX void convert() { v0 = T * v0; v2 = T * v2; ld alpha = atan2(v0) - atan2(v2); - while(alpha > M_PI) alpha -= 360*degree; - while(alpha < -M_PI) alpha += 360*degree; + cyclefix(alpha, 0); sh.angles.push_back(alpha); } if(debugflags & DF_GEOM) { @@ -2117,7 +2116,7 @@ EX void choose() { } EX pair rep_ideal(ld e, ld u IS(1)) { - ld alpha = 2 * M_PI / e; + ld alpha = TAU / e; hyperpoint h1 = point3(cos(alpha)*u, -sin(alpha)*u, 1); hyperpoint h2 = point3(u, 0, 1); hyperpoint h3 = point3(cos(alpha)*u, sin(alpha)*u, 1); @@ -2129,7 +2128,7 @@ EX pair rep_ideal(ld e, ld u IS(1)) { auto Th23 = T * h23; ld beta = atan2(T0); ld gamma = atan2(Th23); - return {len, 90 * degree - (gamma - beta)}; + return {len, 90._deg - (gamma - beta)}; } EX void swap_vertices() { diff --git a/archimedean.cpp b/archimedean.cpp index 2e6f840e..145efa34 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -447,22 +447,22 @@ void archimedean_tiling::compute_geometry() { if(real_faces == 2) { /* standard methods fail for dihedra, but the answer is easy */ - edgelength = 2 * M_PI / faces[0]; + edgelength = TAU / faces[0]; for(int i=0; i 1500) pts = 1500; if(ISMOBILE && pts > 72) pts = 72; for(int r=0; rset_all(0, lband_shift); diff --git a/binary-tiling.cpp b/binary-tiling.cpp index 16013d21..33bc95ed 100644 --- a/binary-tiling.cpp +++ b/binary-tiling.cpp @@ -478,7 +478,7 @@ EX namespace bt { } if(d == NODIR) return 0; if(d == c->type-1) d++; - return -(d+2)*M_PI/4; + return -(d+2) * 45._deg; } transmatrix adj(heptagon *h, int dir) override { @@ -726,20 +726,20 @@ EX namespace bt { } if(geometry == gHoroTris) { ld r3 = sqrt(3); - direct_tmatrix[0] = xpush(-log(2)) * cspin(1,2, M_PI); + direct_tmatrix[0] = xpush(-log(2)) * cspin180(1,2); direct_tmatrix[1] = parabolic3(0, +r3/3) * xpush(-log(2)); direct_tmatrix[2] = parabolic3(-0.5, -r3/6) * xpush(-log(2)); direct_tmatrix[3] = parabolic3(+0.5, -r3/6) * xpush(-log(2)); - direct_tmatrix[4] = parabolic3(0, -r3*2/3) * cspin(1,2, M_PI); - direct_tmatrix[5] = parabolic3(1, r3/3) * cspin(1,2,M_PI); - direct_tmatrix[6] = parabolic3(-1, r3/3) * cspin(1,2,M_PI); + direct_tmatrix[4] = parabolic3(0, -r3*2/3) * cspin180(1,2); + direct_tmatrix[5] = parabolic3(1, r3/3) * cspin180(1,2); + direct_tmatrix[6] = parabolic3(-1, r3/3) * cspin180(1,2); } if(geometry == gHoroRec) { ld r2 = sqrt(2); ld l = -log(2)/2; ld z = hororec_scale; - direct_tmatrix[0] = parabolic3(0, -z) * xpush(l) * cspin(2,1,M_PI/2); - direct_tmatrix[1] = parabolic3(0, +z) * xpush(l) * cspin(2,1,M_PI/2); + direct_tmatrix[0] = parabolic3(0, -z) * xpush(l) * cspin90(2,1); + direct_tmatrix[1] = parabolic3(0, +z) * xpush(l) * cspin90(2,1); direct_tmatrix[2] = parabolic3(+2*r2*z, 0); direct_tmatrix[3] = parabolic3(0, +4*z); direct_tmatrix[4] = parabolic3(-2*r2*z, 0); @@ -749,9 +749,9 @@ EX namespace bt { // also generated with the help of hexb.cpp ld l = log(3)/2; auto& t = direct_tmatrix; - t[0] = parabolic3(horohex_scale, 0) * xpush(-l) * cspin(1, 2, M_PI/2); - t[1] = cspin(1, 2, 2*M_PI/3) * t[0]; - t[2] = cspin(1, 2, 4*M_PI/3) * t[0]; + t[0] = parabolic3(horohex_scale, 0) * xpush(-l) * cspin(1, 2, 90._deg); + t[1] = cspin(1, 2, 120*degree) * t[0]; + t[2] = cspin(1, 2, 240*degree) * t[0]; auto it = iso_inverse(t[0]); t[5] = it * t[1] * t[1]; @@ -978,7 +978,7 @@ EX int celldistance3_hex(heptagon *c1, heptagon *c2) { while(isize(d1)) { xsteps -= 2; - T = euscalezoom(hpxy(0,sqrt(3))) * eupush(1,0) * spin(-d2.back() * 2 * M_PI/3) * T * spin(d1.back() * 2 * M_PI/3) * eupush(-1,0) * euscalezoom(hpxy(0,-1/sqrt(3))); + T = euscalezoom(hpxy(0,sqrt(3))) * eupush(1,0) * spin(-d2.back() * 120._deg) * T * spin(d1.back() * 2 * M_PI/3) * eupush(-1,0) * euscalezoom(hpxy(0,-1/sqrt(3))); d1.pop_back(); d2.pop_back(); @@ -1166,7 +1166,7 @@ EX void create_faces() { hyperpoint down = point3(0,0,2*z); for(int j=0; j<4; j++) for(int i=0; i<3; i++) { - transmatrix T = cspin(0, 1, 2*M_PI*i/3); + transmatrix T = cspin(0, 1, 120._deg * i); hyperpoint hcenter = point3(0,0,-z); hyperpoint hu0 = T*point3(+h, +r3,-z); diff --git a/blizzard.cpp b/blizzard.cpp index 9273c035..d7bb393f 100644 --- a/blizzard.cpp +++ b/blizzard.cpp @@ -241,7 +241,7 @@ EX void drawArrowTraps() { hyperpoint trel = inverse_shift(tu, tC0(tv)); shiftmatrix tpartial = tu * rspintox(trel) * xpush(hdist0(trel) * tt / 401.0); tpartial = tpartial * ypush(.05); - if(GDIM == 3) tpartial = tpartial * cspin(1, 2, M_PI/2); + if(GDIM == 3) tpartial = tpartial * cspin90(1, 2); queuepoly(tpartial, cgi.shTrapArrow, 0xFFFFFFFF); } } diff --git a/cell.cpp b/cell.cpp index 57b94d08..be1d92d5 100644 --- a/cell.cpp +++ b/cell.cpp @@ -1071,7 +1071,7 @@ int ld_to_int(ld x) { #if CAP_ARCM EX gp::loc pseudocoords(cell *c) { transmatrix T = arcm::archimedean_gmatrix[c->master].second; - return {ld_to_int(T[0][LDIM]), ld_to_int((spin(60*degree) * T)[0][LDIM])}; + return {ld_to_int(T[0][LDIM]), ld_to_int((spin(60._deg) * T)[0][LDIM])}; } EX cdata *arcmCdata(cell *c) { diff --git a/celldrawer.cpp b/celldrawer.cpp index 1b33117d..b5eb0d38 100644 --- a/celldrawer.cpp +++ b/celldrawer.cpp @@ -88,7 +88,9 @@ void celldrawer::addaura() { void eclectic_red(color_t& col) { part(col, 0) = part(col, 2) * 3 / 4; } - + +constexpr ld spinspeed = .75 / M_PI; + void celldrawer::setcolors() { wcol = fcol = winf[c->wall].color; @@ -105,7 +107,7 @@ void celldrawer::setcolors() { 0x90 + 8 * sintick(1000, windmap::windcodes[windmap::getId(c)] / 256.) ) : #endif - 0x1010C0 + int(32 * sintick(500, (ls::any_chaos() ? c->CHAOSPARAM : c->landparam)*.75/M_PI)); + 0x1010C0 + int(32 * sintick(500, (ls::any_chaos() ? c->CHAOSPARAM : c->landparam)*spinspeed)); else if(c->land == laOceanWall) fcol = 0x2020FF; else if(c->land == laVariant) @@ -118,7 +120,7 @@ void celldrawer::setcolors() { if(c->move(i)->wall != waSea && c->move(i)->wall != waBoat) nearshore = true; if(nearshore) mafcol += 30; */ - fcol = fcol + mafcol * (4+sintick(500, ((eubinary||c->master->alt) ? celldistAlt(c) : 0)*.75/M_PI))/5; + fcol = fcol + mafcol * (4+sintick(500, ((eubinary||c->master->alt) ? celldistAlt(c) : 0)*spinspeed))/5; } else if(c->land == laDocks) { fcol = 0x0000A0; @@ -126,7 +128,7 @@ void celldrawer::setcolors() { else if(c->land == laAlchemist) fcol = 0x900090; else if(c->land == laWhirlpool) - fcol = 0x0000C0 + int(32 * sintick(200, ((eubinary||c->master->alt) ? celldistAlt(c) : 0)*.75/M_PI)); + fcol = 0x0000C0 + int(32 * sintick(200, ((eubinary||c->master->alt) ? celldistAlt(c) : 0)*spinspeed)); else if(c->land == laLivefjord) fcol = 0x000080; else if(isWarpedType(c->land)) @@ -638,7 +640,7 @@ void celldrawer::tune_colors() { celldist(c); int dc = - 0x10101 * (127 + int(127 * sintick(200, d*.75/M_PI))); + 0x10101 * (127 + int(127 * sintick(200, d*spinspeed))); wcol = gradient(wcol, dc, 0, .3, 1); fcol = gradient(fcol, dc, 0, .3, 1); } @@ -686,7 +688,7 @@ void celldrawer::draw_wall() { int hdir = 0; for(int i=0; itype; i++) if(c->move(i)->wall == waClosedGate) hdir = i; - queuepolyat(V * ddspin(c, hdir, M_PI), cgi.shPalaceGate, darkena(wcol, 0, 0xFF), wmspatial?PPR::WALL3A:PPR::WALL); + queuepolyat(V * ddspin180(c, hdir), cgi.shPalaceGate, darkena(wcol, 0, 0xFF), wmspatial?PPR::WALL3A:PPR::WALL); return; } color_t wcol0 = wcol; @@ -712,7 +714,7 @@ void celldrawer::draw_wall() { int hdir = 0; for(int i=0; itype; i++) if(c->move(i) && c->move(i)->wall == waClosedGate) hdir = i; - shiftmatrix V2 = mscale(V, wmspatial?cgi.WALL:1) * ddspin(c, hdir, M_PI); + shiftmatrix V2 = mscale(V, wmspatial?cgi.WALL:1) * ddspin180(c, hdir); queuepolyat(V2, cgi.shPalaceGate, darkena(wcol, 0, 0xFF), wmspatial?PPR::WALL3A:PPR::WALL); starcol = 0; } @@ -787,7 +789,7 @@ void celldrawer::draw_boat() { Vboat = V; nospin = c->wall == waBoat && applyAnimation(c, Vboat, footphase, LAYER_BOAT); if(!nospin) Vboat = face_the_player(V); - else Vboat = Vboat * cspin(0, 2, M_PI); + else Vboat = Vboat * cspin180(0, 2); queuepolyat(mscale(Vboat, cgi.scalefactor/2), cgi.shBoatOuter, outcol, PPR::BOATLEV2); queuepolyat(mscale(Vboat, cgi.scalefactor/2-0.01), cgi.shBoatInner, incol, PPR::BOATLEV2); return; @@ -795,7 +797,7 @@ void celldrawer::draw_boat() { if(wmspatial && c->wall == waBoat) { nospin = c->wall == waBoat && applyAnimation(c, Vboat, footphase, LAYER_BOAT); - if(!nospin && c->mondir != NODIR) Vboat = Vboat * ddspin(c, c->mondir, M_PI); + if(!nospin && c->mondir != NODIR) Vboat = Vboat * ddspin180(c, c->mondir); queuepolyat(Vboat, cgi.shBoatOuter, outcol, PPR::BOATLEV); Vboat = V; } @@ -803,7 +805,7 @@ void celldrawer::draw_boat() { nospin = applyAnimation(c, Vboat, footphase, LAYER_BOAT); } if(!nospin && c->mondir != NODIR) - Vboat = Vboat * ddspin(c, c->mondir, M_PI); + Vboat = Vboat * ddspin180(c, c->mondir); else { shiftmatrix Vx; if(applyAnimation(c, Vx, footphase, LAYER_SMALL)) @@ -964,7 +966,7 @@ void celldrawer::draw_halfvine() { queuepolyat(GDIM == 2 ? Vdepth : V2, cgi.shSemiFloor[0], darkena(vcol, fd, 0xFF), PPR::WALL3A); if(!noshadow) { dynamicval p(poly_outline, OUTLINE_TRANS); - queuepolyat(V2 * spin(M_PI*2/3), cgi.shSemiFloorShadow, SHADOW_WALL, GDIM == 2 ? PPR::WALLSHADOW : PPR::TRANSPARENT_SHADOW); + queuepolyat(V2 * spin(120._deg), cgi.shSemiFloorShadow, SHADOW_WALL, GDIM == 2 ? PPR::WALLSHADOW : PPR::TRANSPARENT_SHADOW); } #if MAXMDIM >= 4 if(GDIM == 3 && qfi.fshape) { @@ -1032,7 +1034,7 @@ void celldrawer::draw_mirrorwall() { queuepolyat(V2, cgi.shHalfMirror[2], 0xC0C0C080, PPR::WALL3); } else { - qfi.spin = ddspin(c, d, M_PI); + qfi.spin = ddspin180(c, d); shiftmatrix V2 = V * qfi.spin; if(!wmblack) { inmirrorcount++; @@ -1526,7 +1528,7 @@ void celldrawer::draw_features() { queuepoly(V, cgi.shThorns, 0xC080C0FF); for(int u=0; u<4; u+=2) - queuepoly(V * spin(2*M_PI / 3 / 4 * u), cgi.shRose, darkena(wcol, 0, 0xC0)); + queuepoly(V * spin(30._deg * u), cgi.shRose, darkena(wcol, 0, 0xC0)); break; } @@ -1712,7 +1714,7 @@ void celldrawer::draw_features() { ld rad = cgi.hexf * (.3 * (u + ds)); int tcol = darkena(gradient(forecolor, backcolor, 0, rad, 1.5 * cgi.hexf), 0, 0xFF); PRING(a) - curvepoint(xspinpush0(a * M_PI / cgi.S42, rad)); + curvepoint(xspinpush0(a * cgi.S_step, rad)); queuecurve(V, tcol, 0, PPR::LINE); } } @@ -1904,7 +1906,7 @@ void celldrawer::check_rotations() { ds.point = normalize_flat(ds.total); if(prod) ds.point = zshift(ds.point, ds.depth / ds.qty); if(side == 2) for(int i=0; i<3; i++) ds.point[i] = -ds.point[i]; - if(side == 1) ds.point = spin(-M_PI/2) * ds.point; + if(side == 1) ds.point = spin(-90._deg) * ds.point; } }; @@ -2535,7 +2537,7 @@ void celldrawer::add_map_effects() { cell *c2 = c->move(i); if(airdist(c2) < airdist(c)) { ld airdir = calcAirdir(c2); // printf("airdir = %d\n", airdir); - transmatrix V0 = ddspin(c, i, M_PI); + transmatrix V0 = ddspin180(c, i); double ph = ptick(PURE?150:75) + airdir; @@ -2570,7 +2572,7 @@ void celldrawer::add_map_effects() { for(int t=0; ttype; t++) if(c->move(t)) { if(c->move(t)->ligon) { int lcol = darkena(gradient(iinf[itOrbLightning].color, 0, 0, tim, 1100), 0, 0xFF); - queueline(V*chei(xspinpush((vid.flasheffects ? ticks : ptick(8)) * M_PI / cgi.S42, cgi.hexf/2), rand() % 1000, 1000) * C0, V*chei(currentmap->adj(c, t), rand() % 1000, 1000) * C0, lcol, 2 + vid.linequality); + queueline(V*chei(xspinpush((vid.flasheffects ? ticks : ptick(8)) * cgi.S_step, cgi.hexf/2), rand() % 1000, 1000) * C0, V*chei(currentmap->adj(c, t), rand() % 1000, 1000) * C0, lcol, 2 + vid.linequality); } for(int u: {-1, 1}) { cellwalker cw = cellwalker(c, t) + wstep + u; @@ -2578,7 +2580,7 @@ void celldrawer::add_map_effects() { cell *c2 = cw.peek(); if(c2 && c2->ligon) { int lcol = darkena(gradient(iinf[itOrbLightning].color, 0, 0, tim, 1100), 0, 0xFF); - queueline(V*chei(xspinpush((vid.flasheffects ? ticks : ptick(8)) * M_PI / cgi.S42, cgi.hexf/2), rand() % 1000, 1000) * C0, V*chei(currentmap->adj(c, t)*currentmap->adj(cw.at, cw.spin), rand() % 1000, 1000) * C0, lcol, 2 + vid.linequality); + queueline(V*chei(xspinpush((vid.flasheffects ? ticks : ptick(8)) * cgi.S_step, cgi.hexf/2), rand() % 1000, 1000) * C0, V*chei(currentmap->adj(c, t)*currentmap->adj(cw.at, cw.spin), rand() % 1000, 1000) * C0, lcol, 2 + vid.linequality); } } } @@ -2596,8 +2598,7 @@ void celldrawer::add_map_effects() { int aircol = 0xC0C0FF40; - if(hdir1 < hdir0-M_PI) hdir1 += 2 * M_PI; - if(hdir1 >= hdir0+M_PI) hdir1 -= 2 * M_PI; + cyclefix(hdir1, hdir0); ld hdir = (hdir1*ph1+hdir0*(1-ph1)); @@ -2733,7 +2734,7 @@ void celldrawer::draw() { inmirrorcount += cmc; draw_grid(); if(cw2.mirrored != cw.mirrored) V = V * Mirror; - if(cw2.spin) V = V * spin(2*M_PI*cw2.spin/cw2.at->type); + if(cw2.spin) V = V * spin(TAU*cw2.spin/cw2.at->type); cw2.spin = 0; dynamicval dc(cwtV, cwtV); cwtV = V * inverse_shift(ggmatrix(cw2.at), cwtV); diff --git a/colors.cpp b/colors.cpp index 1dc89683..cc0e4917 100644 --- a/colors.cpp +++ b/colors.cpp @@ -247,13 +247,15 @@ EX int cloakcolor(int rtr) { EX int firegradient(double p) { return gradient(0xFFFF00, 0xFF0000, 0, p, 1); } - + +constexpr ld PI1000 = 0.001 / A_PI; + EX int firecolor(int phase IS(0), int mul IS(1)) { - return gradient(0xFFFF00, 0xFF0000, -1, sintick(100*mul, phase/200./M_PI), 1); + return gradient(0xFFFF00, 0xFF0000, -1, sintick(100*mul, phase * 5 * PI1000), 1); } EX int watercolor(int phase) { - return 0x0080C0FF + 256 * int(63 * sintick(50, phase/100./M_PI)); + return 0x0080C0FF + 256 * int(63 * sintick(50, phase * 10 * PI1000)); } EX int aircolor(int phase) { @@ -270,7 +272,7 @@ EX int fghostcolor(cell *c) { } EX int weakfirecolor(int phase) { - return gradient(0xFF8000, 0xFF0000, -1, sintick(500, phase/1000./M_PI), 1); + return gradient(0xFF8000, 0xFF0000, -1, sintick(500, phase * PI1000), 1); } /* HTML color names */ diff --git a/commandline.cpp b/commandline.cpp index c6b9815b..d181e5d1 100644 --- a/commandline.cpp +++ b/commandline.cpp @@ -256,31 +256,31 @@ int arg::readCommon() { PHASE(3); start_game(); shift(); ld a = argf(); shift(); ld b = argf(); - View = View * spin(M_PI * 2 * a / b); + View = View * spin(TAU * a / b); playermoved = false; } else if(argis("-rotate-up")) { start_game(); shiftmatrix S = ggmatrix(cwt.at->master->move(0)->c7); - View = spin(90*degree) * spintox(S.T*C0) * View; + View = spin90() * spintox(S.T*C0) * View; playermoved = false; } else if(argis("-rotate3")) { PHASE(3); start_game(); shift(); ld a = argf(); shift(); ld b = argf(); - View = View * cspin(1, 2, M_PI * 2 * a / b); + View = View * cspin(1, 2, TAU * a / b); playermoved = false; } else if(argis("-face-vertex")) { PHASE(3); start_game(); auto &ss = currentmap->get_cellshape(cwt.at); - View = cspin(0, 2, M_PI/2) * spintox(ss.vertices_only_local[0]); + View = cspin90(0, 2) * spintox(ss.vertices_only_local[0]); playermoved = false; } else if(argis("-face-face")) { PHASE(3); start_game(); - View = cspin(0, 2, M_PI/2); + View = cspin90(0, 2); } else if(argis("-grotate")) { PHASE(3); start_game(); diff --git a/complex2.cpp b/complex2.cpp index 1f2836a5..b803e10c 100644 --- a/complex2.cpp +++ b/complex2.cpp @@ -1239,7 +1239,7 @@ EX namespace dice { } } - shiftmatrix V1 = V * ddspin(c, dir) * spin(M_PI); + shiftmatrix V1 = V * ddspin(c, dir + M_PI); if(dd.mirrored) V1 = V1 * MirrorY; // loop: @@ -1260,8 +1260,8 @@ EX namespace dice { if(1) { dynamicval g(geometry, gSphere); - ld alpha = 360 * degree / dw->order; - ld beta = 180 * degree / dw->facesides; + ld alpha = TAU / dw->order; + ld beta = M_PI / dw->facesides; inradius = edge_of_triangle_with_angles(alpha, beta, beta); outradius = edge_of_triangle_with_angles(beta, alpha, beta); } @@ -1320,7 +1320,7 @@ EX namespace dice { for(int d=0; d g(geometry, highdim); - add_to_queue(T * cspin(0, 1, 2*M_PI*d/si) * cspin(2, 0, inradius) * cspin(0, 1, M_PI-2*M_PI*dw->spins[ws][d]/si), dw->sides[ws][d]); + add_to_queue(T * cspin(0, 1, TAU*d/si) * cspin(2, 0, inradius) * cspin(0, 1, M_PI-TAU*dw->spins[ws][d]/si), dw->sides[ws][d]); } if(1) { @@ -1363,7 +1363,7 @@ EX namespace dice { hyperpoint h, hs; if(1) { dynamicval g(geometry, highdim); - h = zpush(base_to_base) * T * cspin(0, 1, 2*M_PI*(d+.5)/si) * cspin(2, 0, outradius) * zpush0(dieradius); + h = zpush(base_to_base) * T * cspin(0, 1, TAU*(d+.5)/si) * cspin(2, 0, outradius) * zpush0(dieradius); if(d < si) face[d] = h; hs = sphere_to_space(h); } diff --git a/config.cpp b/config.cpp index 84cd88e7..fe93a677 100644 --- a/config.cpp +++ b/config.cpp @@ -1005,7 +1005,7 @@ EX void initConfig() { if(ginf[i].flags & qELLIPTIC) sightranges[i] = M_PI; else if(ginf[i].cclass == gcSphere) - sightranges[i] = 2 * M_PI; + sightranges[i] = TAU; else if(ginf[i].cclass == gcEuclid) sightranges[i] = 10; else if(ginf[i].cclass == gcSL2) @@ -1028,21 +1028,21 @@ EX void initConfig() { addsaver(sightranges[gBinary3], "sight-binary3", 3.1 + bonus); addsaver(sightranges[gCubeTiling], "sight-cubes", 10); - addsaver(sightranges[gCell120], "sight-120cell", 2 * M_PI); + addsaver(sightranges[gCell120], "sight-120cell", TAU); addsaver(sightranges[gECell120], "sight-120cell-elliptic", M_PI); addsaver(sightranges[gRhombic3], "sight-rhombic", 10.5 * emul); addsaver(sightranges[gBitrunc3], "sight-bitrunc", 12 * emul); addsaver(sightranges[gSpace534], "sight-534", 4 + bonus); addsaver(sightranges[gSpace435], "sight-435", 3.8 + bonus); - addsaver(sightranges[gCell5], "sight-5cell", 2 * M_PI); - addsaver(sightranges[gCell8], "sight-8cell", 2 * M_PI); + addsaver(sightranges[gCell5], "sight-5cell", TAU); + addsaver(sightranges[gCell8], "sight-8cell", TAU); addsaver(sightranges[gECell8], "sight-8cell-elliptic", M_PI); - addsaver(sightranges[gCell16], "sight-16cell", 2 * M_PI); + addsaver(sightranges[gCell16], "sight-16cell", TAU); addsaver(sightranges[gECell16], "sight-16cell-elliptic", M_PI); - addsaver(sightranges[gCell24], "sight-24cell", 2 * M_PI); + addsaver(sightranges[gCell24], "sight-24cell", TAU); addsaver(sightranges[gECell24], "sight-24cell-elliptic", M_PI); - addsaver(sightranges[gCell600], "sight-600cell", 2 * M_PI); + addsaver(sightranges[gCell600], "sight-600cell", TAU); addsaver(sightranges[gECell600], "sight-600cell-elliptic", M_PI); addsaver(sightranges[gHoroTris], "sight-horotris", 2.9 + bonus); addsaver(sightranges[gHoroRec], "sight-hororec", 2.2 + bonus); @@ -1402,14 +1402,14 @@ EX void edit_sightrange() { if(GDIM == 3) { dialog::addSelItem(XLAT("3D sight range for the fog effect"), fts(sightranges[geometry]), 'r'); dialog::add_action([] { - dialog::editNumber(sightranges[geometry], 0, 2 * M_PI, 0.5, M_PI, XLAT("fog effect"), ""); + dialog::editNumber(sightranges[geometry], 0, TAU, 0.5, M_PI, XLAT("fog effect"), ""); }); } } if(WDIM == 3) { dialog::addSelItem(XLAT("3D sight range"), fts(sightranges[geometry]), 'r'); dialog::add_action([] { - dialog::editNumber(sightranges[geometry], 0, 2 * M_PI, 0.5, M_PI, XLAT("3D sight range"), + dialog::editNumber(sightranges[geometry], 0, TAU, 0.5, M_PI, XLAT("3D sight range"), XLAT( "Sight range for 3D geometries is specified in the absolute units. This value also affects the fog effect.\n\n" "In spherical geometries, the sight range of 2π will let you see things behind you as if they were in front of you, " @@ -2403,7 +2403,7 @@ EX int config3 = addHook(hooks_configfile, 100, [] { param_f(linepatterns::parallel_count, "parallel_count") ->editable(0, 24, 1, "number of parallels drawn", "", 'n'); param_f(linepatterns::parallel_max, "parallel_max") - ->editable(0, 360*degree, 15*degree, "last parallel drawn", "", 'n'); + ->editable(0, TAU, 15*degree, "last parallel drawn", "", 'n'); param_f(vid.depth_bonus, "depth_bonus", 0) ->editable(-5, 5, .1, "depth bonus in pseudohedral", "", 'b'); param_b(vid.pseudohedral, "pseudohedral", false) @@ -2588,7 +2588,7 @@ EX void showCustomizeChar() { initquickqueue(); transmatrix V = atscreenpos(vid.xres/2, firsty, scale); - double alpha = atan2(mousex - vid.xres/2, mousey - firsty) - M_PI/2; + double alpha = atan2(mousex - vid.xres/2, mousey - firsty) - 90._deg; V = V * spin(alpha); drawMonsterType(moPlayer, NULL, shiftless(V), 0, cc_footphase / scale, NOCOLOR); quickqueue(); diff --git a/control.cpp b/control.cpp index d15f7105..fceb5647 100644 --- a/control.cpp +++ b/control.cpp @@ -99,7 +99,6 @@ EX movedir vectodir(hyperpoint P) { ld d1 = geo_dist(U * T * C0, Centered * P); ld d2 = geo_dist(U * T * C0, Centered * C0); dirdist[i] = d1 - d2; - //xspinpush0(-i * 2 * M_PI /cwt.at->type, .5), P); } movedir res; @@ -122,11 +121,9 @@ EX void remission() { } EX hyperpoint move_destination_vec(int d) { - if(WDIM == 2) return spin(-d * M_PI/4) * smalltangent(); - // else if(WDIM == 2 && pmodel == mdPerspective) return cspin(0, 2, d * M_PI/4) * tC0(pushone()); - // else if(WDIM == 2) return spin(-d * M_PI/4) * tC0(pushone()); - else if(d&1) return cspin(0, 1, d > 4 ? M_PI/2 : -M_PI/2) * smalltangent(); - else return cspin(0, 2, d * M_PI/4) * smalltangent(); + if(WDIM == 2) return spin(-d * 45._deg) * smalltangent(); + else if(d&1) return cspin(0, 1, d > 4 ? 45._deg : -45._deg) * smalltangent(); + else return cspin(0, 2, d * 45._deg) * smalltangent(); } EX void movepckeydir(int d) { @@ -401,7 +398,7 @@ EX void full_rotate_camera(int dir, ld val) { else if(GDIM == 3) { val *= camera_rot_speed; if(third_person_rotation) shift_view(ctangent(2, -third_person_rotation)), didsomething = true, playermoved = false; - ld max_angle = quarter_circle - 1e-4; + ld max_angle = 90._deg - 1e-4; if(walking::on && dir == 1) { max_angle /= degree; walking::eye_angle += val * walking::eye_angle_scale / degree; @@ -461,8 +458,8 @@ EX void handlePanning(int sym, int uni) { } #endif if(!smooth_scrolling) { - if(sym == SDLK_PAGEUP) full_rotate_view(1, M_PI/cgi.S21/2*shiftmul); - if(sym == SDLK_PAGEDOWN) full_rotate_view(-1, -M_PI/cgi.S21/2*shiftmul); + if(sym == SDLK_PAGEUP) full_rotate_view(1, cgi.S_step*shiftmul); + if(sym == SDLK_PAGEDOWN) full_rotate_view(-1, -cgi.S_step*shiftmul); if(sym == SDLK_PAGEUP || sym == SDLK_PAGEDOWN) if(isGravityLand(cwt.at->land) && !rug::rug_control()) playermoved = false; } @@ -925,8 +922,8 @@ EX void mainloopiter() { if(keystate[SDL_SCANCODE_LEFT] && DEFAULTNOR(SDL_SCANCODE_LEFT)) full_rotate_camera(0, t); if(keystate[SDL_SCANCODE_UP] && DEFAULTNOR(SDL_SCANCODE_UP)) full_rotate_camera(1, t); if(keystate[SDL_SCANCODE_DOWN] && DEFAULTNOR(SDL_SCANCODE_DOWN)) full_rotate_camera(1, -t); - if(keystate[SDL_SCANCODE_PAGEUP] && DEFAULTNOR(SDL_SCANCODE_PAGEUP)) full_rotate_view(t * 180 / M_PI, t); - if(keystate[SDL_SCANCODE_PAGEDOWN] && DEFAULTNOR(SDL_SCANCODE_PAGEDOWN)) full_rotate_view(-t * 180 / M_PI, -t); + if(keystate[SDL_SCANCODE_PAGEUP] && DEFAULTNOR(SDL_SCANCODE_PAGEUP)) full_rotate_view(t / degree, t); + if(keystate[SDL_SCANCODE_PAGEDOWN] && DEFAULTNOR(SDL_SCANCODE_PAGEDOWN)) full_rotate_view(-t / degree, -t); #else @@ -936,8 +933,8 @@ EX void mainloopiter() { if(keystate[SDLK_LEFT] && DEFAULTNOR(SDLK_LEFT)) full_rotate_camera(0, t); if(keystate[SDLK_UP] && DEFAULTNOR(SDLK_UP)) full_rotate_camera(1, t); if(keystate[SDLK_DOWN] && DEFAULTNOR(SDLK_DOWN)) full_rotate_camera(1, -t); - if(keystate[SDLK_PAGEUP] && DEFAULTNOR(SDLK_PAGEUP)) full_rotate_view(t * 180 / M_PI, t); - if(keystate[SDLK_PAGEDOWN] && DEFAULTNOR(SDLK_PAGEDOWN)) full_rotate_view(-t * 180 / M_PI, -t); + if(keystate[SDLK_PAGEUP] && DEFAULTNOR(SDLK_PAGEUP)) full_rotate_view(t / degree, t); + if(keystate[SDLK_PAGEDOWN] && DEFAULTNOR(SDLK_PAGEDOWN)) full_rotate_view(-t / degree, -t); #endif } else sc_ticks = ticks; @@ -952,8 +949,8 @@ EX void mainloopiter() { if(keystate['a'] && DEFAULTNOR('a')) full_rotate_camera(0, t); if(keystate['w'] && DEFAULTNOR('w')) full_rotate_camera(1, t); if(keystate['s'] && DEFAULTNOR('s')) full_rotate_camera(1, -t); - if(keystate['q'] && DEFAULTNOR('q')) full_rotate_view(t * 180 / M_PI, t); - if(keystate['e'] && DEFAULTNOR('e')) full_rotate_view(-t * 180 / M_PI, -t); + if(keystate['q'] && DEFAULTNOR('q')) full_rotate_view(t / degree, t); + if(keystate['e'] && DEFAULTNOR('e')) full_rotate_view(-t / degree, -t); if(keystate['i'] && GDIM == 3 && DEFAULTNOR('i')) full_forward_camera(-t); if(keystate['k'] && GDIM == 3 && DEFAULTNOR('k')) full_forward_camera(t); diff --git a/crystal.cpp b/crystal.cpp index 88bc526e..7ed57b4e 100644 --- a/crystal.cpp +++ b/crystal.cpp @@ -801,7 +801,7 @@ EX colortable coordcolors = {0xD04040, 0x40D040, 0x4040D0, 0xFFD500, 0xF000F0, 0 EX ld compass_angle() { bool bitr = ginf[gCrystal].vertex == 3; - return (bitr ? M_PI/8 : 0) - master_to_c7_angle(); + return (bitr ? 22.5_deg : 0) - master_to_c7_angle(); } EX bool crystal_cell(cell *c, shiftmatrix V) { @@ -822,7 +822,7 @@ EX bool crystal_cell(cell *c, shiftmatrix V) { ld dist = cellgfxdist(c, 0); for(int i=0; ihcoords[c->master]; auto lw = m->makewalker(co, i); @@ -1118,8 +1118,9 @@ EX void init_rotation() { if(ho & 1) { for(int i=(draw_cut ? 2 : cs.dim-1); i>=1; i--) { - ld c = cos(M_PI / 2 / (i+1)); - ld s = sin(M_PI / 2 / (i+1)); + ld alpha = 90._deg / (i+1); + ld c = cos(alpha); + ld s = sin(alpha); for(int j=0; j cx = ", cx, " darken = ", part(col, 0)); auravertices.emplace_back(hyperpoint(cx - current_display->xcenter, by - current_display->ycenter, 0, 1), col); @@ -754,7 +754,7 @@ EX namespace dialog { color_t col = addalpha(I.color); ld sizf = dfsize * I.scale / 150; ld siz = sizf * sqrt(0.15+0.85*I.param/255.); - for(int i=0; i<=a; i++) curvepoint(hyperpoint(siz * sin(i*2*M_PI/a), -siz * cos(i*2*M_PI/a), 1, 1)); + for(int i=0; i<=a; i++) curvepoint(hyperpoint(siz * sin(i*TAU/a), -siz * cos(i*TAU/a), 1, 1)); shiftmatrix V = shiftless(atscreenpos(valuex + sizf, mid, pix)); queuecurve(V, col, (I.colorv << 8) | 0xFF, PPR::LINE); quickqueue(); diff --git a/drawing.cpp b/drawing.cpp index fbc58626..84081eb5 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -439,10 +439,10 @@ void addpoint(const shiftpoint& H) { if(sphere && pmodel == mdSpiral) { if(isize(glcoords)) { hyperpoint Hscr1; - shiftpoint H1 = H; H1.shift += 2 * M_PI; + shiftpoint H1 = H; H1.shift += TAU; applymodel(H1, Hscr1); if(hypot_d(2, Hlast-Hscr1) < hypot_d(2, Hlast-Hscr)) { Hscr = Hscr1; } - H1.shift -= 4 * M_PI; + H1.shift -= 2 * TAU; applymodel(H1, Hscr1); if(hypot_d(2, Hlast-Hscr1) < hypot_d(2, Hlast-Hscr)) { Hscr = Hscr1; } } @@ -1108,7 +1108,7 @@ EX namespace s2xe { } void add2(pt h, int gen) { - glcoords.push_back(glhr::pointtogl(point31(sin(h[0]) * (h[1] + 2 * M_PI * gen), cos(h[0]) * (h[1] + 2 * M_PI * gen), h[2]))); + glcoords.push_back(glhr::pointtogl(point31(sin(h[0]) * (h[1] + TAU * gen), cos(h[0]) * (h[1] + TAU * gen), h[2]))); stinf.tvertices.push_back(glhr::makevertex(h[3], h[4], 0)); } @@ -1125,13 +1125,13 @@ EX namespace s2xe { bool to_right(const pt& h2, const pt& h1) { ld x2 = h2[0]; ld x1 = h1[0]; - if(x2 < x1) x2 += 2 * M_PI; + if(x2 < x1) x2 += TAU; return x2 >= x2 && x2 <= x1 + M_PI; } EX int qrings = 32; - ld seg() { return 2 * M_PI / qrings; } + ld seg() { return TAU / qrings; } void add_ortho_triangle(pt bl, pt tl, pt br, pt tr) { @@ -1164,12 +1164,12 @@ EX namespace s2xe { } void add_ordered_triangle(array v) { - if(v[1][0] < v[0][0]) v[1][0] += 2 * M_PI; - if(v[2][0] < v[1][0]) v[2][0] += 2 * M_PI; + if(v[1][0] < v[0][0]) v[1][0] += TAU; + if(v[2][0] < v[1][0]) v[2][0] += TAU; if(v[2][0] - v[0][0] < 1e-6) return; ld x = (v[1][0] - v[0][0]) / (v[2][0] - v[0][0]); - if(v[2][0] < v[0][0] + M_PI / 4 && maxy < M_PI - M_PI/4 && sightranges[geometry] <= 5) { + if(v[2][0] < v[0][0] + 45._deg && maxy < 135._deg && sightranges[geometry] <= 5) { addall(v[0], v[1], v[2]); return; } @@ -1195,16 +1195,16 @@ EX namespace s2xe { } void add_triangle_around(array v) { - ld baseheight = (v[0][1] > M_PI/2) ? M_PI : 0; + ld baseheight = (v[0][1] > 90._deg) ? M_PI : 0; ld tu = (v[0][3] + v[1][3] + v[2][3]) / 3; ld tv = (v[0][4] + v[1][4] + v[2][4]) / 3; array vhigh; for(int i=0; i<3; i++) { vhigh[i] = v[i]; vhigh[i][1] = baseheight; vhigh[i][3] = tu; vhigh[i][4] = tv; } - if(v[1][0] < v[0][0]) v[1][0] = v[1][0] + 2 * M_PI, vhigh[1][0] = vhigh[1][0] + 2 * M_PI; + if(v[1][0] < v[0][0]) v[1][0] = v[1][0] + TAU, vhigh[1][0] = vhigh[1][0] + TAU; add_ortho_triangle(v[0], vhigh[0], v[1], vhigh[1]); - if(v[2][0] < v[1][0]) v[2][0] = v[2][0] + 2 * M_PI, vhigh[2][0] = vhigh[2][0] + 2 * M_PI; + if(v[2][0] < v[1][0]) v[2][0] = v[2][0] + TAU, vhigh[2][0] = vhigh[2][0] + TAU; add_ortho_triangle(v[1], vhigh[1], v[2], vhigh[2]); - if(v[0][0] < v[2][0]) v[0][0] = v[0][0] + 2 * M_PI, vhigh[0][0] = vhigh[0][0] + 2 * M_PI; + if(v[0][0] < v[2][0]) v[0][0] = v[0][0] + TAU, vhigh[0][0] = vhigh[0][0] + TAU; add_ortho_triangle(v[2], vhigh[2], v[0], vhigh[0]); } @@ -1215,12 +1215,12 @@ EX namespace s2xe { minz = min(abs(v[0][2]), max(abs(v[1][2]), abs(v[2][2]))); auto& s = sightranges[geometry]; - maxgen = sqrt(s * s - minz * minz) / (2 * M_PI) + 1; + maxgen = sqrt(s * s - minz * minz) / TAU + 1; maxy = max(v[0][1], max(v[1][1], v[2][1])); miny = min(v[0][1], min(v[1][1], v[2][1])); with_zero = true; - if(maxy < M_PI / 4) { + if(maxy < 45._deg) { add2(v[0], 0); add2(v[1], 0); add2(v[2], 0); @@ -1310,7 +1310,7 @@ void draw_s2xe0(dqi_poly *p) { set_width(1); glcoords.clear(); - int maxgen = sightranges[geometry] / (2 * M_PI) + 1; + int maxgen = sightranges[geometry] / TAU + 1; auto crossdot = [&] (const hyperpoint h1, const hyperpoint h2) { return make_pair(h1[0] * h2[1] - h1[1] * h2[0], h1[0] * h2[0] + h1[1] * h2[1]); }; vector pd; @@ -1342,7 +1342,7 @@ void draw_s2xe0(dqi_poly *p) { for(int i=0; icnt; i++) { auto &c1 = pd[i]; auto &c0 = pd[i==0?p->cnt-1 : i-1]; - if(c1.distance > M_PI/2 && c0.distance > M_PI/2 && crossdot(c0.direction, c1.direction).second < 0) return; + if(c1.distance > 90._deg && c0.distance > 90._deg && crossdot(c0.direction, c1.direction).second < 0) return; if(c1.bad == 2) return; if(c1.bad == 1) no_gens = true; } @@ -1354,12 +1354,12 @@ void draw_s2xe0(dqi_poly *p) { angles[i] = atan2(pd[i].direction[1], pd[i].direction[0]); } sort(angles.begin(), angles.end()); - angles.push_back(angles[0] + 2 * M_PI); + angles.push_back(angles[0] + TAU); bool ok = false; for(int i=1; i= angles[i-1] + M_PI) ok = true; if(!ok) { - for(auto &c: pd) if(c.distance > M_PI/2) return; + for(auto &c: pd) if(c.distance > 90._deg) return; no_gens = true; } } @@ -1369,7 +1369,7 @@ void draw_s2xe0(dqi_poly *p) { for(int gen=-g; gen<=g; gen++) { for(int i=0; icnt; i++) { auto& cur = pd[i]; - ld d = cur.distance + 2 * M_PI * gen; + ld d = cur.distance + TAU * gen; hyperpoint h; h[0] = cur.direction[0] * d; h[1] = cur.direction[1] * d; @@ -1572,9 +1572,9 @@ EX namespace ods { for(int j=0; j<6; j++) { // let Delta be from 0 to 2PI - if(h[j][2]<0) h[j][2] += 2 * M_PI; + if(h[j][2]<0) h[j][2] += TAU; // Theta is from -PI/2 to PI/2. Let it be from 0 to PI - h[j][1] += global_projection * M_PI/2; + h[j][1] += global_projection * 90._deg; h[j][3] = 1; } @@ -1591,8 +1591,8 @@ EX namespace ods { cyclefix(h[4][0], h[3][0]); cyclefix(h[5][0], h[3][0]); - if(abs(h[1][1] - h[0][1]) > M_PI/2) goto next_i; - if(abs(h[2][1] - h[0][1]) > M_PI/2) goto next_i; + if(abs(h[1][1] - h[0][1]) > 90._deg) goto next_i; + if(abs(h[2][1] - h[0][1]) > 90._deg) goto next_i; if(h[0][0] < -M_PI || h[0][0] > M_PI) println(hlog, h[0][0]); @@ -1601,7 +1601,7 @@ EX namespace ods { if(h[1][0] < -M_PI || h[2][0] < -M_PI) lst++; if(h[1][0] > +M_PI || h[2][0] > +M_PI) fst--; for(int x=fst; x<=lst; x++) for(int j=0; j<3; j++) { - glcoords.push_back(glhr::makevertex(h[j][0] + 2 * M_PI * x, h[j][1], h[j][2])); + glcoords.push_back(glhr::makevertex(h[j][0] + TAU * x, h[j][1], h[j][2])); if(npoly.tinf) stinf.tvertices.push_back(p->tinf->tvertices[p->offset_texture+i+j]); } } diff --git a/fake.cpp b/fake.cpp index 23bea690..4c2069e7 100644 --- a/fake.cpp +++ b/fake.cpp @@ -237,19 +237,17 @@ EX namespace fake { auto h1 = V * befake(FPIU(get_corner_position(c, (i+1) % c->type))); ld b0 = atan2(unshift(h0)); ld b1 = atan2(unshift(h1)); - while(b1 < b0) b1 += 2 * M_PI; + while(b1 < b0) b1 += TAU; if(a0 == -1) { draw_recursive(c->move(i), optimized_shift(V * adj(c, i)), b0, b1, c, depth+1); } else { if(b1 - b0 > M_PI) continue; - if(b0 < a0 - M_PI) b0 += 2 * M_PI; - if(b0 > a0 + M_PI) b0 -= 2 * M_PI; + cyclefix(b0, a0); if(b0 < a0) b0 = a0; - if(b1 > a1 + M_PI) b1 -= 2 * M_PI; - if(b1 < a1 - M_PI) b1 += 2 * M_PI; + cyclefix(b1, a1); if(b1 > a1) b1 = a1; if(b0 > b1) continue; diff --git a/floorshapes.cpp b/floorshapes.cpp index 6806141c..cc321c0c 100644 --- a/floorshapes.cpp +++ b/floorshapes.cpp @@ -106,17 +106,17 @@ mesher msh(eGeometry g, int sym, ld main, ld v0, ld v1, ld bspi, ld scale) { dynamicval dg(geometry, g); hyperpoint rot = xpush(v0) * xspinpush0(M_PI - M_PI/sym, main); - hyperpoint bnlfar = xpush(v0) * spin(M_PI) * rspintox(rot) * rspintox(rot) * rspintox(rot) * xpush0(hdist0(rot)); - hyperpoint bnrfar = xpush(v0) * spin(M_PI) * spintox(rot) * spintox(rot) * spintox(rot) * xpush0(hdist0(rot)); + hyperpoint bnlfar = xpush(v0) * spin180() * rspintox(rot) * rspintox(rot) * rspintox(rot) * xpush0(hdist0(rot)); + hyperpoint bnrfar = xpush(v0) * spin180() * spintox(rot) * spintox(rot) * spintox(rot) * xpush0(hdist0(rot)); - m.lcorner = xspinpush0 (bspi-M_PI/sym, main); - m.rcorner = xspinpush0 (bspi+M_PI/sym, main); + m.lcorner = xspinpush0 (bspi - M_PI/sym, main); + m.rcorner = xspinpush0 (bspi + M_PI/sym, main); m.mfar[0] = xspinpush0 (bspi, v0); m.mfar[1] = xspinpush0 (bspi, v1); m.vfar[0] = spin(bspi) * bnlfar; m.vfar[2] = spin(bspi) * bnrfar; - m.vfar[1] = spin(-2*M_PI/sym) * m.vfar[2]; - m.vfar[3] = spin(+2*M_PI/sym) * m.vfar[0]; + m.vfar[1] = spin(-TAU/sym) * m.vfar[2]; + m.vfar[3] = spin(+TAU/sym) * m.vfar[0]; return m; } @@ -131,7 +131,7 @@ matrixitem genitem(const transmatrix& m1, const transmatrix& m2, int nsym) { mi.first = m1; mi.second.resize(nsym); for(int i=0; ib[0], 0xFFFFFFFF); if(sh == &cgi.shCrossFloor) { - queuepoly(shiftless(eupush(gx, gy) * spin(M_PI/4)), cgi.shCross, 0x808080FF); + queuepoly(shiftless(eupush(gx, gy) * spin(45._deg)), cgi.shCross, 0x808080FF); } if(1) { @@ -1237,8 +1237,8 @@ void draw_shape_for_texture(floorshape* sh) { ld d = hdist(h1, h2); hyperpoint h3 = h1 + (h2-h1) /d * min(d, .1); for(int a=0; a<4; a++) { - curvepoint(eupush(gx,gy) * eupush(spin(90*degree*a) * h1) * C0); - curvepoint(eupush(gx,gy) * eupush(spin(90*degree*a) * h3) * C0); + curvepoint(eupush(gx,gy) * eupush(spin(90._deg*a) * h1) * C0); + curvepoint(eupush(gx,gy) * eupush(spin(90._deg*a) * h3) * C0); queuecurve(shiftless(Id), 0x10101010, 0, PPR::LINE); } } diff --git a/geom-exp.cpp b/geom-exp.cpp index 350a96ba..3d5c615e 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -901,7 +901,7 @@ EX geometry_data compute_geometry_data() { gd.size_str = disksize ? its(isize(currentmap->allcells())) : #if CAP_BT - bt::in() ? fts(8 * M_PI * sqrt(2) * log(2) / pow(vid.binary_width, WDIM-1), 4) + " exp(∞)" : + bt::in() ? fts(1440._deg * sqrt(2) * log(2) / pow(vid.binary_width, WDIM-1), 4) + " exp(∞)" : #endif #if CAP_ARCM arcm::in() && (WDIM == 2) ? arcm::current.world_size() : diff --git a/geometry.cpp b/geometry.cpp index ade445ff..60021ea8 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -410,6 +410,7 @@ hpcshape hpcshape shFullCross[2]; int SD3, SD6, SD7, S12, S14, S21, S28, S42, S36, S84; + ld S_step; vector> walloffsets; @@ -582,7 +583,7 @@ void geometry_information::prepare_basics() { hexshift = 0; - ld ALPHA = 2 * M_PI / S7; + ld ALPHA = TAU / S7; ld fmin, fmax; @@ -612,7 +613,7 @@ void geometry_information::prepare_basics() { t->hcrossf = cgi.crossf / d; t->tessf = cgi.tessf / d; t->hexvdist = cgi.hexvdist / d; - t->hexhexdist = hdist(xpush0(cgi.hcrossf), xspinpush0(M_PI*2/S7, cgi.hcrossf)) / d; + t->hexhexdist = hdist(xpush0(cgi.hcrossf), xspinpush0(TAU/S7, cgi.hcrossf)) / d; t->base_distlimit = cgi.base_distlimit-1; }); goto hybrid_finish; @@ -629,13 +630,13 @@ void geometry_information::prepare_basics() { s3 = S3; if(fake::in() && !arcm::in()) s3 = fake::around; - beta = (S3 >= OINF && !fake::in()) ? 0 : 2*M_PI/s3; + beta = (S3 >= OINF && !fake::in()) ? 0 : TAU/s3; tessf = euclid ? 1 : edge_of_triangle_with_angles(beta, M_PI/S7, M_PI/S7); - if(elliptic && S7 == 4 && !fake::in()) tessf = M_PI/2; + if(elliptic && S7 == 4 && !fake::in()) tessf = 90._deg; - hcrossf = euclid ? tessf / 2 / sin(M_PI/s3) : edge_of_triangle_with_angles(M_PI/2, M_PI/S7, beta/2); + hcrossf = euclid ? tessf / 2 / sin(M_PI/s3) : edge_of_triangle_with_angles(90._deg, M_PI/S7, beta/2); if(S3 >= OINF) hcrossf = 10; @@ -645,15 +646,15 @@ void geometry_information::prepare_basics() { for(int p=0; p<100; p++) { ld f = (fmin+fmax) / 2; hyperpoint H = xpush0(f); - hyperpoint H1 = spin(2*M_PI/S7) * H; + hyperpoint H1 = spin(TAU/S7) * H; hyperpoint H2 = xpush0(tessf-f); ld v1 = intval(H, H1), v2 = intval(H, H2); if(fake::in() && WDIM == 2) { hexvdist = hdist(xpush0(f), xspinpush0(ALPHA/2, hcrossf)); v2 = hdist( - spin(M_PI/2/S3) * xpush0(hexvdist), - spin(-M_PI/2/S3) * xpush0(hexvdist) + spin(90._deg/S3) * xpush0(hexvdist), + spin(-90._deg/S3) * xpush0(hexvdist) ); v1 = hdist( @@ -667,7 +668,7 @@ void geometry_information::prepare_basics() { hexf = fmin; rhexf = BITRUNCATED ? hexf : hcrossf; - edgelen = hdist(xpush0(rhexf), xspinpush0(M_PI*2/S7, rhexf)); + edgelen = hdist(xpush0(rhexf), xspinpush0(TAU/S7, rhexf)); if(BITRUNCATED && !(S7&1)) hexshift = ALPHA/2 + ALPHA * ((S7-1)/2) + M_PI; @@ -690,7 +691,7 @@ void geometry_information::prepare_basics() { hexhexdist = fake::in() ? 2 * hdist0(mid(xspinpush0(M_PI/S6, hexvdist), xspinpush0(-M_PI/S6, hexvdist))) - : hdist(xpush0(crossf), xspinpush0(M_PI*2/S7, crossf)); + : hdist(xpush0(crossf), xspinpush0(TAU/S7, crossf)); DEBB(DF_GEOM | DF_POLY, (format("S7=%d S6=%d hexf = " LDF" hcross = " LDF" tessf = " LDF" hexshift = " LDF " hexhex = " LDF " hexv = " LDF "\n", S7, S6, hexf, hcrossf, tessf, hexshift, @@ -968,7 +969,7 @@ EX namespace geom3 { BIRD = 1.20; } else { - INFDEEP = GDIM == 3 ? (sphere ? M_PI/2 : +5) : (euclid || sphere) ? 0.01 : lev_to_projection(0) * tanh(vid.camera); + INFDEEP = GDIM == 3 ? (sphere ? 90._deg : +5) : (euclid || sphere) ? 0.01 : lev_to_projection(0) * tanh(vid.camera); ld wh = actual_wall_height(); WALL = lev_to_factor(wh); FLOOR = lev_to_factor(0); @@ -1091,8 +1092,8 @@ EX void switch_always3() { ld ms = min(cgi.scalefactor, 1); vid.wall_height = 1.5 * ms; if(sphere) { - vid.depth = M_PI / 6; - vid.wall_height = M_PI / 3; + vid.depth = 30 * degree; + vid.wall_height = 60 * degree; } vid.human_wall_ratio = 0.8; if(euclid && allowIncreasedSight() && vid.use_smart_range == 0) { diff --git a/geometry2.cpp b/geometry2.cpp index 76f4b2af..ece327bf 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -57,7 +57,7 @@ transmatrix hrmap_standard::master_relative(cell *c, bool get_inverse) { #if CAP_IRR else if(IRREGULAR) { int id = irr::cellindex[c]; - ld alpha = 2 * M_PI / S7 * irr::periodmap[c->master].base.spin; + ld alpha = TAU / S7 * irr::periodmap[c->master].base.spin; return get_inverse ? irr::cells[id].rpusher * spin(-alpha-master_to_c7_angle()): spin(alpha + master_to_c7_angle()) * irr::cells[id].pusher; } #endif @@ -100,12 +100,12 @@ transmatrix hrmap_standard::adj(heptagon *h, int d) { int t0 = h->type; int t1 = h->cmove(d)->type; int sp = h->c.spin(d); - return spin(-d * 2 * M_PI / t0) * xpush(spacedist(h->c7, d)) * spin(M_PI + 2*M_PI*sp/t1); + return spin(-d * TAU / t0) * xpush(spacedist(h->c7, d)) * spin(M_PI + TAU * sp / t1); } transmatrix T = cgi.heptmove[d]; if(h->c.mirror(d)) T = T * Mirror; int sp = h->c.spin(d); - if(sp) T = T * spin(2*M_PI*sp/S7); + if(sp) T = T * spin(TAU*sp/S7); return T; } @@ -443,7 +443,7 @@ EX bool no_easy_spin() { ld hrmap_standard::spin_angle(cell *c, int d) { if(WDIM == 3) return SPIN_NOT_AVAILABLE; ld hexshift = 0; - if(c == c->master->c7 && (S7 % 2 == 0) && BITRUNCATED) hexshift = cgi.hexshift + 2*M_PI/c->type; + if(c == c->master->c7 && (S7 % 2 == 0) && BITRUNCATED) hexshift = cgi.hexshift + TAU/c->type; else if(cgi.hexshift && c == c->master->c7) hexshift = cgi.hexshift; #if CAP_IRR if(IRREGULAR) { @@ -454,7 +454,7 @@ ld hrmap_standard::spin_angle(cell *c, int d) { return -atan2(p[1], p[0]) - hexshift; } #endif - return M_PI - d * 2 * M_PI / c->type - hexshift; + return M_PI - d * TAU / c->type - hexshift; } EX transmatrix ddspin(cell *c, int d, ld bonus IS(0)) { return currentmap->spin_to(c, d, bonus); } @@ -543,14 +543,14 @@ EX hyperpoint randomPointIn(int t) { if(NONSTDVAR || arcm::in() || kite::in()) { // Let these geometries be less confusing. // Also easier to implement ;) - return xspinpush0(2 * M_PI * randd(), asinh(randd() / 20)); + return xspinpush0(TAU * randd(), asinh(randd() / 20)); } while(true) { - hyperpoint h = xspinpush0(2*M_PI*(randd()-.5)/t, asinh(randd())); + hyperpoint h = xspinpush0(TAU * (randd()-.5)/t, asinh(randd())); double d = PURE ? cgi.tessf : t == 6 ? cgi.hexhexdist : cgi.crossf; if(hdist0(h) < hdist0(xpush(-d) * h)) - return spin(2*M_PI/t * (rand() % t)) * h; + return spin(TAU / t * (rand() % t)) * h; } } @@ -612,7 +612,7 @@ EX hyperpoint nearcorner(cell *c, int i) { auto& t = ac.get_triangle(c->master, i-1); int id = arcm::id_of(c->master); int id1 = ac.get_adj(ac.get_adj(c->master, i-1), -2).first; - return xspinpush0(-t.first - M_PI / c->type, ac.inradius[id/2] + ac.inradius[id1/2] + (ac.real_faces == 0 ? 2 * M_PI / (ac.N == 2 ? 2.1 : ac.N) : 0)); + return xspinpush0(-t.first - M_PI / c->type, ac.inradius[id/2] + ac.inradius[id1/2] + (ac.real_faces == 0 ? TAU / (ac.N == 2 ? 2.1 : ac.N) : 0)); } if(BITRUNCATED) { auto &ac = arcm::current; diff --git a/goldberg.cpp b/goldberg.cpp index 0c2fea88..336d7a37 100644 --- a/goldberg.cpp +++ b/goldberg.cpp @@ -646,12 +646,12 @@ EX namespace gp { } if(sp>SG3) sp -= SG6; - return normalize(spin(2*M_PI*sp/S7) * cornmul(T, corner)); + return normalize(spin(TAU*sp/S7) * cornmul(T, corner)); } transmatrix dir_matrix(int i) { auto ddspin = [] (int d) -> transmatrix { - return spin(M_PI - d * 2 * M_PI / S7 - cgi.hexshift); + return spin(M_PI - d * TAU / S7 - cgi.hexshift); }; return spin(-cgi.gpdata->alpha) * build_matrix( C0, @@ -678,7 +678,7 @@ EX namespace gp { hyperpoint h = atz(T, cgi.gpdata->corners, at, 6); hyperpoint hl = atz(T, cgi.gpdata->corners, at + eudir(d), 6); - cgi.gpdata->Tf[i][x&GOLDBERG_MASK][y&GOLDBERG_MASK][d] = rgpushxto0(h) * rspintox(gpushxto0(h) * hl) * spin(M_PI); + cgi.gpdata->Tf[i][x&GOLDBERG_MASK][y&GOLDBERG_MASK][d] = rgpushxto0(h) * rspintox(gpushxto0(h) * hl) * spin180(); } } } diff --git a/graph.cpp b/graph.cpp index 725c6270..9db5f0c8 100644 --- a/graph.cpp +++ b/graph.cpp @@ -45,6 +45,9 @@ EX bool hide_player() { ; } +EX transmatrix ddspin180(cell *c, int dir) { return ddspin(c, dir, M_PI); } +EX transmatrix iddspin180(cell *c, int dir) { return iddspin(c, dir, M_PI); } + #if HDR template class span { @@ -74,11 +77,11 @@ EX int animation_lcm = 0; EX ld ptick(int period, ld phase IS(0)) { if(animation_lcm) animation_lcm = animation_lcm * (period / gcd(animation_lcm, period)); - return (ticks * animation_factor * vid.ispeed) / period + phase * 2 * M_PI; + return (ticks * animation_factor * vid.ispeed) / period + phase * TAU; } EX ld fractick(int period, ld phase IS(0)) { - ld t = ptick(period, phase) / 2 / M_PI; + ld t = ptick(period, phase) / TAU; t -= floor(t); if(t<0) t++; return t; @@ -137,7 +140,7 @@ EX bool doHighlight() { int dlit; ld spina(cell *c, int dir) { - return 2 * M_PI * dir / c->type; + return TAU * dir / c->type; } /** @brief used to alternate colors depending on distance to something. In chessboard-patterned geometries, also use a third step */ @@ -186,7 +189,7 @@ EX void drawShield(const shiftmatrix& V, eItem it) { #endif else { for(ld a=0; a<=cgi.S84*mt+1e-6; a+=pow(.5, vid.linequality)) - curvepoint(xspinpush0(a * M_PI/cgi.S42, d + sin(ds + M_PI*2*a/4/mt)*.1)); + curvepoint(xspinpush0(a * cgi.S_step, d + sin(ds + 90._deg*a/mt)*.1)); queuecurve(V, darkena(col, 0, 0xFF), 0x8080808, PPR::LINE); } #endif @@ -202,7 +205,7 @@ void drawSpeed(const shiftmatrix& V, ld scale=1) { #endif for(int b=0; bcgi.S42) z = cgi.S84-z; if(z <= 10) d += (10-z) * (10-z) * (10-z) / 3000.; ld rad = cgi.hexf * (2.5 + .5 * sin(ds+u*.3)) * d; - curvepoint(xspinpush0((cgi.S42+hdir+a-1) * M_PI/cgi.S42, rad)); + curvepoint(xspinpush0((cgi.S42+hdir+a-1) * cgi.S_step, rad)); } queuecurve(V1, col, 0x8080808, PPR::LINE); } @@ -292,7 +295,7 @@ void drawWinter(const shiftmatrix& V, ld hdir, color_t col) { float ds = ptick(300); col = darkena(col, 0, 0xFF); for(int u=0; u<20; u++) { - ld rad = sin(ds+u * 2 * M_PI / 20) * M_PI / S7; + ld rad = sin(ds+u * TAU / 20) * M_PI / S7; shiftmatrix V1 = chei(V, u, 20); queueline(V1*xspinpush0(M_PI+hdir+rad, cgi.hexf*.5), V1*xspinpush0(M_PI+hdir+rad, cgi.hexf*3), col, 2 + vid.linequality); } @@ -312,7 +315,7 @@ void drawLightning(const shiftmatrix& V) { else { if(u % 5) leng = 1.25 + sintick(200, ld(u) * 1.25) * 0.25; else leng = 2 + sintick(200, ld(u) * 1.25); - rad = (u + ds) * (M_PI / 10); + rad = (u + ds) * TAU / 20; } shiftmatrix V1 = chei(V, u, 20); queueline(V1*xspinpush0(rad, cgi.hexf*0.3), V1*xspinpush0(rad, cgi.hexf*leng), col, 2 + vid.linequality); @@ -332,7 +335,7 @@ void drawCurse(const shiftmatrix& V, eItem it) { } else { leng = 0.85 + sintick(150, ld(u) * 1.25) * 0.15; - rad = (u + ds) * (M_PI / 10); + rad = (u + ds) * TAU / 20; } shiftmatrix V1 = chei(V, u, 20); queueline(V1*xspinpush0(rad, cgi.hexf*0.3), V1*xspinpush0(rad, cgi.hexf*leng), col, 2 + vid.linequality); @@ -368,7 +371,7 @@ EX void drawPlayerEffects(const shiftmatrix& V, const shiftmatrix& Vparam, cell else if(SWORDDIM == 3) { #if CAP_SHAPES shiftmatrix Vsword = - shmup::on ? V * shmup::swordmatrix[multi::cpid] * cspin(2, 0, M_PI/2) + shmup::on ? V * shmup::swordmatrix[multi::cpid] * cspin90(2, 0) : Vparam * rgpushxto0(inverse_shift(gmatrix[c], tC0(V))) * sword::dir[multi::cpid].T; if(items[itOrbSword]) @@ -384,7 +387,7 @@ EX void drawPlayerEffects(const shiftmatrix& V, const shiftmatrix& Vparam, cell ang %= sword::sword_angles; #if CAP_QUEUE || CAP_SHAPES - shiftmatrix Vnow = Vparam * rgpushxto0(inverse_shift(Vparam, tC0(V))) * ddspin(c,0,M_PI); + shiftmatrix Vnow = Vparam * rgpushxto0(inverse_shift(Vparam, tC0(V))) * ddspin180(c,0); #endif int adj = 1 - ((sword_angles/cwt.at->type)&1); @@ -444,7 +447,7 @@ EX void drawPlayerEffects(const shiftmatrix& V, const shiftmatrix& Vparam, cell ld rad = cgi.hexf * u / 250; color_t col = darkena(iinf[itOrbSafety].color, 0, 0xFF); PRING(a) - curvepoint(xspinpush0(a * M_PI / cgi.S42, rad)); + curvepoint(xspinpush0(a * cgi.S_step, rad)); queuecurve(V, col, 0, PPR::LINE); } } @@ -453,7 +456,7 @@ EX void drawPlayerEffects(const shiftmatrix& V, const shiftmatrix& Vparam, cell void drawStunStars(const shiftmatrix& V, int t) { #if CAP_SHAPES for(int i=0; i<3*t; i++) { - shiftmatrix V2 = V * spin(M_PI * 2 * i / (3*t) + ptick(200)); + shiftmatrix V2 = V * spin(TAU * i / (3*t) + ptick(200)); #if MAXMDIM >= 4 if(GDIM == 3) V2 = V2 * zpush(cgi.HEAD); #endif @@ -519,7 +522,7 @@ EX namespace tortoise { if(d > 0) mcol = 0xFFFFFF; else if(d < 0) mcol = 0; - int dd = 0xFF * (atan(fabs(d)/2) / (M_PI/2)); + int dd = 0xFF * (atan(fabs(d)/2) / 90._deg); return gradient(0x487830, mcol, 0, dd, 0xFF); } @@ -754,7 +757,7 @@ EX shiftmatrix face_the_player(const shiftmatrix V) { if(vrhr::enabled) { shiftpoint h = tC0(V); hyperpoint uh = unshift(h); - return shiftless(cspin(1, 2, 90*degree) * rspintox(cspin(2, 1, 90*degree) * uh) * xpush(hdist0(uh)) * cspin(0, 2, 90*degree) * cspin(1, 0, 90*degree)); + return shiftless(cspin90(1, 2) * rspintox(cspin90(2, 1) * uh) * xpush(hdist0(uh)) * cspin90(0, 2) * spin270()); } #endif return rgpushxto0(tC0(V)); @@ -853,7 +856,7 @@ EX bool drawItemType(eItem it, cell *c, const shiftmatrix& V, color_t icol, int #if CAP_SHAPES auto sinptick = [c, pticks] (int period) { return c ? sintick(period) : sin(animation_factor * vid.ispeed * pticks / period);}; - auto spinptick = [c, pticks] (int period, ld phase) { return c ? spintick(period, phase) : spin((animation_factor * vid.ispeed * pticks) / period + phase * 2 * M_PI); }; + auto spinptick = [c, pticks] (int period, ld phase) { return c ? spintick(period, phase) : spin((animation_factor * vid.ispeed * pticks) / period + phase * TAU); }; int ct6 = c ? ctof(c) : 1; hpcshape *xsh = (it == itPirate || it == itKraken) ? &cgi.shPirateX : @@ -1005,16 +1008,14 @@ EX bool drawItemType(eItem it, cell *c, const shiftmatrix& V, color_t icol, int else if(it == itRose) { for(int u=0; u<4; u++) - queuepoly(Vit * spinptick(1500, 0) * spin(2*M_PI / 3 / 4 * u), cgi.shRoseItem, darkena(icol, 0, hidden ? 0x30 : 0xA0)); + queuepoly(Vit * spinptick(1500, 0) * spin(30._deg * u), cgi.shRoseItem, darkena(icol, 0, hidden ? 0x30 : 0xA0)); } else if(it == itBarrow && c) { for(int i = 0; ilandparam; i++) - queuepolyat(Vit * spin(2 * M_PI * i / c->landparam) * xpush(.15) * spinptick(1500, 0), *xsh, darkena(icol, 0, hidden ? 0x40 : + queuepolyat(Vit * spin(TAU * i / c->landparam) * xpush(.15) * spinptick(1500, 0), *xsh, darkena(icol, 0, hidden ? 0x40 : (highwall(c) && wmspatial) ? 0x60 : 0xFF), PPR::HIDDEN); - -// queuepoly(Vit*spin(M_PI+(1-2*ang)*2*M_PI/cgi.S84), cgi.shMagicSword, darkena(0xC00000, 0, 0x80 + 0x70 * sin(ticks / 200.0))); } else if(xsh) { @@ -1072,12 +1073,12 @@ EX bool drawItemType(eItem it, cell *c, const shiftmatrix& V, color_t icol, int auto dark = darkena(icol1, 0, inice ? 0x80 : hidden ? 0x20 : (it == itOrbBeauty) ? 0xA0 : 0xC0); auto dark1 = darkena(icol1, 0, inice ? 0x40 : hidden ? 0x10 : (it == itOrbBeauty) ? 0x50 : 0x60); if(c && GDIM == 2) Vit = rgpushxto0(tC0(Vit)); - auto Vit1 = Vit * spin(90 * degree); + auto Vit1 = Vit * spin90(); if (it == itOrbBeauty) { queuepolyat(Vit, cgi.shDisk, dark1, prio); for(int u=0; u<3; u++) - queuepolyat(Vit1 * spin(2*M_PI / 3 / 3 * u), cgi.shSmallRose, dark, prio); + queuepolyat(Vit1 * spin(40._deg * u), cgi.shSmallRose, dark, prio); } else if (it == itOrbLife) { queuepolyat(Vit, cgi.shDisk, dark1, prio); @@ -1113,7 +1114,7 @@ EX bool drawItemType(eItem it, cell *c, const shiftmatrix& V, color_t icol, int queuepolyat(Vit, cgi.shDisk, dark1, prio); queuepolyat(Vit, cgi.shDiskM, dark, prio); for (int i=0; i<5; i++) { - shiftmatrix V2 = Vit * spin(2*M_PI * i / 5 + ptick(300)); + shiftmatrix V2 = Vit * spin(TAU * i / 5 + ptick(300)); queuepolyat(V2, cgi.shSmallFlailBall, dark, prio); } } @@ -1189,7 +1190,7 @@ EX bool drawItemType(eItem it, cell *c, const shiftmatrix& V, color_t icol, int bool reversed = (shape == &cgi.shTreeIcon || shape == &cgi.shHumanoid || it == itOrbSword2); bool left90 = (shape == &cgi.shLeafIcon || shape == &cgi.shLightningBolt); if (shape) - queuepolyat(reversed ? Vit1 * MirrorX : left90 ? Vit1 * spin(-90*degree) : Vit1, *shape, (it == itOrbInvis || it == itOrbTeleport) ? 0x20 : 0x80, prio); + queuepolyat(reversed ? Vit1 * MirrorX : left90 ? Vit1 * spin270() : Vit1, *shape, (it == itOrbInvis || it == itOrbTeleport) ? 0x20 : 0x80, prio); if (it == itOrbSide1 || (shape == &cgi.shEccentricDisk && it != itOrbDiscord)) queuepolyat(Vit1*Mirror, *shape, 0x80, prio); if (jump || it == itOrbEnergy) @@ -1381,7 +1382,7 @@ EX void drawPlayer(eMonster m, cell *where, const shiftmatrix& V, color_t col, d } if(items[itOrbSide1] && !shmup::on) - queuepoly(VBODY * VBS * spin(-M_PI/24), cs.charid >= 2 ? cgi.shSabre : cgi.shPSword, fc(314, cs.swordcolor, 3)); // 3 not colored + queuepoly(VBODY * VBS * spin(-15._deg), cs.charid >= 2 ? cgi.shSabre : cgi.shPSword, fc(314, cs.swordcolor, 3)); // 3 not colored shiftmatrix VWPN = cs.lefthanded ? VBODY * VBS * Mirror : VBODY * VBS; @@ -1451,7 +1452,7 @@ EX int wingphase(int period, int phase IS(0)) { } transmatrix wingmatrix(int period, int phase = 0) { - ld t = fractick(period, phase) * 2 * M_PI; + ld t = fractick(period, phase) * TAU; transmatrix Vwing = Id; Vwing[1][1] = .85 + .15 * sin(t); return Vwing; @@ -1508,7 +1509,7 @@ void drawMimic(eMonster m, cell *where, const shiftmatrix& V, color_t col, doubl if(items[itOrbThorns] && emp) queuepoly(VBODY * VBS, cgi.shHedgehogBladePlayer, darkena(col, 0, 0x40)); if(items[itOrbSide1] && !shmup::on) - queuepoly(VBODY * VBS * spin(-M_PI/24), cs.charid >= 2 ? cgi.shSabre : cgi.shPSword, darkena(col, 0, 0x40)); + queuepoly(VBODY * VBS * spin(-15._deg), cs.charid >= 2 ? cgi.shSabre : cgi.shPSword, darkena(col, 0, 0x40)); if(items[itOrbSide3] && emp) queuepoly(VBODY * VBS, (cs.charid&1) ? cgi.shFerocityF : cgi.shFerocityM, darkena(col, 0, 0x40)); @@ -1547,7 +1548,7 @@ EX bool drawMonsterType(eMonster m, cell *where, const shiftmatrix& V1, color_t char xch = minf[m].glyph; shiftmatrix V = V1; - if(WDIM == 3 && (classflag(m) & CF_FACE_UP) && where && !hybri) V = V1 * cspin(0, 2, M_PI/2); + if(WDIM == 3 && (classflag(m) & CF_FACE_UP) && where && !hybri) V = V1 * cspin90(0, 2); #if CAP_SHAPES if(among(m, moTortoise, moWorldTurtle) && where && where->stuntime >= 3) @@ -1590,7 +1591,7 @@ EX bool drawMonsterType(eMonster m, cell *where, const shiftmatrix& V1, color_t case moBullet: ShadowV(V, cgi.shKnife); - queuepoly(VBODY * spin(-M_PI/4), cgi.shKnife, getcs().swordcolor); + queuepoly(VBODY * spin270(), cgi.shKnife, getcs().swordcolor); return true; case moKnight: case moKnightMoved: { @@ -2109,7 +2110,7 @@ EX bool drawMonsterType(eMonster m, cell *where, const shiftmatrix& V1, color_t case moJiangshi: { ShadowV(V, cgi.shJiangShi); - auto z2 = WDIM == 3 ? 0 : GDIM == 3 ? -abs(sin(footphase * M_PI * 2)) * cgi.human_height/3 : geom3::lev_to_factor(abs(sin(footphase * M_PI * 2)) * cgi.human_height); + auto z2 = WDIM == 3 ? 0 : GDIM == 3 ? -abs(sin(footphase * TAU)) * cgi.human_height/3 : geom3::lev_to_factor(abs(sin(footphase * TAU)) * cgi.human_height); auto V0 = V; auto V = mmscale(V0, z2); otherbodyparts(V, darkena(col, 0, 0xFF), m, m == moJiangshi ? 0 : footphase); @@ -2328,7 +2329,7 @@ EX bool drawMonsterType(eMonster m, cell *where, const shiftmatrix& V1, color_t case moLancer: case moFlailer: case moMiner: { shiftmatrix V2 = V; if(m == moLancer) - V2 = V * spin((where && where->type == 6) ? -M_PI/3 : -M_PI/2 ); + V2 = V * spin((where && where->type == 6) ? -60._deg : -90._deg ); shiftmatrix Vh = mmscale(V2, cgi.HEAD); shiftmatrix Vb = mmscale(V2, cgi.BODY); Vb = Vb * otherbodyparts(V2, darkena(col, 1, 0xFF), m, footphase); @@ -2512,7 +2513,7 @@ EX bool drawMonsterType(eMonster m, cell *where, const shiftmatrix& V1, color_t } else if(isMagneticPole(m)) { if(m == moNorthPole) - queuepolyat(VBODY * spin(M_PI), cgi.shTentacle, 0x000000C0, PPR::TENTACLE1); + queuepolyat(VBODY * spin180(), cgi.shTentacle, 0x000000C0, PPR::TENTACLE1); queuepolyat(VBODY, cgi.shDisk, darkena(col, 0, 0xFF), PPR::MONSTER_BODY); } else if(isMetalBeast(m) || m == moBrownBug) { @@ -2660,7 +2661,6 @@ EX bool applyAnimation(cell *c, shiftmatrix& V, double& footphase, int layer) { V = V * a.wherenow; if(a.mirrored) V = V * Mirror; if(a.attacking == 2) V = V * pispin; - // if(GDIM == 3) V = V * cspin(0, 2, M_PI/2); a.ltick = ticks; return true; } @@ -2874,7 +2874,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col if(doHighlight()) poly_outline = outline; shiftmatrix Vbx = Vb; - if(WDIM == 2) Vbx = Vbx * spin(sin(M_PI * i / 6.) * wav / (i+.1)); + if(WDIM == 2) Vbx = Vbx * spin(sin(TAU * i / 12) * wav / (i+.1)); Vbx = Vbx * xpush(length * (i) / 12.0); // shiftmatrix Vbx2 = Vnext * xpush(length2 * i / 6.0); // Vbx = Vbx * rspintox(inverse(Vbx) * Vbx2 * C0) * pispin; @@ -2889,7 +2889,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col shiftmatrix T = Vparam * ddspin(c, c->mondir); color_t col = darkena(0x606020, 0, 0xFF); for(int u=-1; u<=1; u++) - queueline(T*xspinpush0(M_PI/2, u*cgi.crossf/5), T*xspinpush(0, cgi.crossf)*xspinpush0(M_PI/2, u*cgi.crossf/5), col, 2 + vid.linequality); + queueline(T*xspinpush0(90._deg, u*cgi.crossf/5), T*xspinpush(0, cgi.crossf)*xspinpush0(90._deg, u*cgi.crossf/5), col, 2 + vid.linequality); } } @@ -2898,7 +2898,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col if(hybri) { queuepoly(Vb, cgi.shILeaf[ctof(c)], darkena(col, 0, 0xFF)); for(int a=0; atype-2; a++) - queuepoly(Vb * spin(a * 2 * M_PI / (c->type-2)), cgi.shILeaf[2], darkena(col, 0, 0xFF)); + queuepoly(Vb * spin(a * TAU / (c->type-2)), cgi.shILeaf[2], darkena(col, 0, 0xFF)); } else if(GDIM == 3) { queuepoly(face_the_player(Vb), cgi.shILeaf[1], darkena(col, 0, 0xFF)); @@ -2949,7 +2949,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col Vb = Vb * pispin; } else { - Vb = Vb0 * ddspin(c, nd, M_PI); + Vb = Vb0 * ddspin180(c, nd); } if(c->monmirror) Vb = Vb * Mirror; shiftmatrix Vbb = mmscale(Vb, cgi.ABODY); @@ -2969,8 +2969,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col /* todo what if no spin_angle */ ld hdir0 = currentmap->spin_angle(c, nd) + M_PI; ld hdir1 = currentmap->spin_angle(c, c->mondir); - while(hdir1 > hdir0 + M_PI) hdir1 -= 2*M_PI; - while(hdir1 < hdir0 - M_PI) hdir1 += 2*M_PI; + cyclefix(hdir1, hdir0); Vb = Vb0 * spin((hdir0 + hdir1)/2 + M_PI); } if(c->monmirror) Vb = Vb * Mirror; @@ -2999,7 +2998,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col Vb = Vb * pispin; } else { - Vb = Vb0 * ddspin(c, nd, M_PI); + Vb = Vb0 * ddspin180(c, nd); } if(c->monmirror) Vb = Vb * Mirror; shiftmatrix Vbb = mmscale(Vb, cgi.ABODY) * pispin; @@ -3087,7 +3086,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col Vb = Vb * T * rspintox(tC0(iso_inverse(T))) * xpush(cgi.tentacle_length); } else { - Vb = Vb * ddspin(c, c->mondir, M_PI); + Vb = Vb * ddspin180(c, c->mondir); Vb = Vb * xpush(cgi.tentacle_length - cellgfxdist(c, c->mondir)); } if(c->monmirror) Vb = Vb * Mirror; @@ -3109,7 +3108,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col else if((hasFacing(c) && c->mondir != NODIR) || history::on || quotient || dont_face_pc) { if(c->monst == moKrakenH) Vs = Vb, nospins = nospinb; - if(!nospins && c->mondir < c->type) Vs = Vs * ddspin(c, c->mondir, M_PI); + if(!nospins && c->mondir < c->type) Vs = Vs * ddspin180(c, c->mondir); if(c->monst == moPair) Vs = Vs * xpush(-.12); if(c->monmirror) Vs = Vs * Mirror; if(isFriendly(c)) drawPlayerEffects(Vs, Vparam, c, c->monst); @@ -3141,7 +3140,7 @@ EX bool drawMonster(const shiftmatrix& Vparam, int ct, cell *c, color_t col, col // cwtV * rgpushxto0(inverse(cwtV) * tC0(Vs)); } if(c->monst == moHunterChanging) - Vs = Vs * (hybri ? spin(M_PI) : cspin(WDIM-2, WDIM-1, M_PI)); + Vs = Vs * (hybri ? spin180() : cspin180(WDIM-2, WDIM-1)); } if(c->monmirror) Vs = Vs * Mirror; @@ -3240,7 +3239,7 @@ void apply_joukowsky_aura(shiftpoint& h) { EX void addauraspecial(shiftpoint h, color_t col, int dir) { if(!haveaura_cached) return; apply_joukowsky_aura(h); - int r = int(2*AURA + dir + atan2(h[1], h[0]) * AURA / 2 / M_PI) % AURA; + int r = int(2*AURA + dir + atan2(h[1], h[0]) * AURA / TAU) % AURA; auraspecials.emplace_back(r, col); } @@ -3248,7 +3247,7 @@ EX void addaura(shiftpoint h, color_t col, int fd) { if(!haveaura_cached) return; apply_joukowsky_aura(h); - int r = gmod(atan2(h[1], h[0]) * AURA / 2 / M_PI, AURA); + int r = gmod(atan2(h[1], h[0]) * AURA / TAU, AURA); aurac[r][3] += auramemo << fd; col = darkened(col); aurac[r][0] += (col>>16)&255; @@ -3322,7 +3321,7 @@ EX void drawaura() { if(cmul>1) cmul=1; if(cmul<0) cmul=0; - ld alpha = AURA * atan2(hx,hy) / (2 * M_PI); + ld alpha = AURA * atan2(hx,hy) / TAU; if(alpha<0) alpha += AURA; if(alpha >= AURA) alpha -= AURA; @@ -3363,7 +3362,7 @@ EX void drawaura() { bool joukowsky = among(pmodel, mdJoukowskyInverted, mdJoukowsky) && hyperbolic && pconf.model_transition < 1; for(int r=0; r<=AURA; r++) for(int z=0; z<11; z++) { - float rr = (M_PI * 2 * r) / AURA; + float rr = (TAU * r) / AURA; float rad0 = inversion ? rad / facs[z] : rad * facs[z]; int rm = r % AURA; ld c = cos(rr); @@ -3467,14 +3466,14 @@ EX int countMinesAround(cell *c) { EX transmatrix applyPatterndir(cell *c, const patterns::patterninfo& si) { if(NONSTDVAR || bt::in()) return Id; - transmatrix V = ddspin(c, si.dir, M_PI); + transmatrix V = ddspin180(c, si.dir); if(si.reflect) V = V * Mirror; if(euclid) return V; - return V * iddspin(c, 0, M_PI); + return V * iddspin180(c, 0); } EX transmatrix applyDowndir(cell *c, const cellfunction& cf) { - return ddspin(c, patterns::downdir(c, cf), M_PI); + return ddspin180(c, patterns::downdir(c, cf)); } void draw_movement_arrows(cell *c, const transmatrix& V, int df) { @@ -3488,7 +3487,7 @@ void draw_movement_arrows(cell *c, const transmatrix& V, int df) { for(int d=0; d<8; d++) { - movedir md = vectodir(spin(-d * M_PI/4) * smalltangent()); + movedir md = vectodir(spin(-d * 45._deg) * smalltangent()); cellwalker xc = cwt + md.d; if(xc.spin != df) continue; xc += wstep; @@ -3504,7 +3503,7 @@ void draw_movement_arrows(cell *c, const transmatrix& V, int df) { if(vid.axes >= 5) keylist += key; else - queuepoly(shiftless(fixrot * spin(-d * M_PI/4)), cgi.shArrow, col); + queuepoly(shiftless(fixrot * spin(-d * 45._deg)), cgi.shArrow, col); if((c->type & 1) && (isStunnable(c->monst) || isPushable(c->wall))) { transmatrix Centered = rgpushxto0(unshift(tC0(cwtV))); @@ -3552,7 +3551,7 @@ EX color_t reptilecolor(cell *c) { ld wavefun(ld x) { return sin(x); - /* x /= (2*M_PI); + /* x /= TAU; x -= (int) x; if(x > .5) return (x-.5) * 2; else return 0; */ @@ -4490,7 +4489,7 @@ EX void drawDirectionalParticle(cell *c, int dir, color_t col, int maxspeed IS(1 int speed = 1 + rand() % maxspeed; auto fd = flashdata(ticks, rand() % 16, c, col, speed); fd.angle = -atan2(tC0(currentmap->adj(c, dir))); - fd.angle += 2 * M_PI * (rand() % 100 - rand() % 100) / 100 / c->type; + fd.angle += TAU * (rand() % 100 - rand() % 100) / 100 / c->type; flashes.push_back(fd); } } @@ -4914,7 +4913,7 @@ EX void draw_flash(struct flashdata& f, const shiftmatrix& V, bool& kill) { ld rad[25]; for(int a=0; a<24; a++) rad[a] = (0.5 + randd() * .3 + 0.5 * (a&1)) / (2.8 + celldistance(f.where, cwt.at) * .2); rad[24] = rad[0]; - for(int a=0; a<24; a++) curvepoint(xspinpush0(15 * degree * a, rad[a])); + for(int a=0; a<24; a++) curvepoint(xspinpush0(TAU * a / 24, rad[a])); queuecurve(V, 0xFF, 0xFF0000FF, PPR::SUPERLINE); } } @@ -4948,7 +4947,7 @@ EX void draw_flash(struct flashdata& f, const shiftmatrix& V, bool& kill) { else #endif { - PRING(a) curvepoint(xspinpush0(a * M_PI / cgi.S42, rad)); + PRING(a) curvepoint(xspinpush0(a * cgi.S_step, rad)); queuecurve(V, flashcol, 0x8080808, PPR::LINE); } } @@ -4969,7 +4968,7 @@ EX void draw_flash(struct flashdata& f, const shiftmatrix& V, bool& kill) { else #endif { - PRING(a) curvepoint(xspinpush0(a * M_PI / cgi.S42, rad)); + PRING(a) curvepoint(xspinpush0(a * cgi.S_step, rad)); queuecurve(V, flashcol, 0x8080808, PPR::LINE); } } @@ -5387,7 +5386,7 @@ EX void drawmovestar(double dx, double dy) { if(rightclick && (d == 2 || d == 6 || d == 3 || d == 5)) col &= 0xFFFFFF3F; if(!leftclick && !rightclick && (d&1)) col &= 0xFFFFFF3F; #endif - queueline(tC0(Centered), Centered * xspinpush0(d * M_PI / 4, cgi.scalefactor/2), col, 3 + vid.linequality); + queueline(tC0(Centered), Centered * xspinpush0(d * 45._deg, cgi.scalefactor/2), col, 3 + vid.linequality); #endif } } @@ -5877,7 +5876,7 @@ EX void restartGraph() { if(!autocheat) linepatterns::clearAll(); if(currentmap) { resetview(); - if(sphere) View = spin(-M_PI/2); + if(sphere) View = spin(-90._deg); } } @@ -6037,7 +6036,7 @@ EX void drawBug(const cellwalker& cw, color_t col) { #if CAP_SHAPES initquickqueue(); shiftmatrix V = ggmatrix(cw.at); - if(cw.spin) V = V * ddspin(cw.at, cw.spin, M_PI); + if(cw.spin) V = V * ddspin180(cw.at, cw.spin); queuepoly(V, cgi.shBugBody, col); quickqueue(); #endif diff --git a/history.cpp b/history.cpp index 238d8d9f..44353b9e 100644 --- a/history.cpp +++ b/history.cpp @@ -40,12 +40,12 @@ namespace spiral { CY = band[0]->h; SX = out->w; SY = out->h; + + ld prec = 2*M_PI*M_PI; - ld k = -2*M_PI*M_PI / log(2.6180339); + ld k = -prec / log(2.6180339); -// cxld mnoznik = cxld(0, M_PI) / cxld(k, M_PI); - - cxld factor = cxld(0, -CY/2/M_PI/M_PI) * cxld(k, M_PI); + cxld factor = cxld(0, -CY/prec) * cxld(k, M_PI); Yshift = CY * k / M_PI; diff --git a/hyperpoint.cpp b/hyperpoint.cpp index a7becfcc..4d26e39b 100644 --- a/hyperpoint.cpp +++ b/hyperpoint.cpp @@ -13,11 +13,18 @@ namespace hr { #if HDR -static const ld full_circle = 2 * M_PI; -static const ld quarter_circle = M_PI / 2; -static const ld degree = M_PI / 180; + +#ifndef M_PI +#define M_PI 3.14159265358979 +#endif + +static constexpr ld A_PI = M_PI; +static const ld TAU = 2 * A_PI; +static const ld degree = A_PI / 180; static const ld golden_phi = (sqrt(5)+1)/2; static const ld log_golden_phi = log(golden_phi); + +constexpr ld operator"" _deg(long double deg) { return deg * A_PI / 180; } #endif eGeometry geometry; @@ -231,10 +238,6 @@ constexpr hyperpoint C03 = hyperpoint(0,0,0,1); // basic functions and types //=========================== -#ifndef M_PI -#define M_PI 3.14159265358979 -#endif - EX ld squar(ld x) { return x*x; } EX int sig(int z) { return ginf[geometry].g.sig[z]; } @@ -284,7 +287,7 @@ EX ld acos_auto(ld x) { /** \brief volume of a three-dimensional ball of radius r in the current isotropic geometry */ EX ld volume_auto(ld r) { switch(cgclass) { - case gcEuclid: return 4 * r * r * r / 3 * M_PI; + case gcEuclid: return r * r * r * 240._deg; case gcHyperbolic: return M_PI * (sinh(2*r) - 2 * r); case gcSphere: return M_PI * (2 * r - sin(2*r)); default: return 0; @@ -295,8 +298,8 @@ EX ld volume_auto(ld r) { EX ld area_auto(ld r) { switch(cgclass) { case gcEuclid: return r * r * M_PI; - case gcHyperbolic: return 2 * M_PI * (cosh(r) - 1); - case gcSphere: return 2 * M_PI * (1 - cos(r)); + case gcHyperbolic: return TAU * (cosh(r) - 1); + case gcSphere: return TAU * (1 - cos(r)); default: return 0; } } @@ -307,7 +310,7 @@ EX ld wvolarea_auto(ld r) { else return area_auto(r); } -EX ld asin_clamp(ld x) { return x>1 ? M_PI/2 : x<-1 ? -M_PI/2 : std::isnan(x) ? 0 : asin(x); } +EX ld asin_clamp(ld x) { return x>1 ? 90._deg : x<-1 ? -90._deg : std::isnan(x) ? 0 : asin(x); } EX ld acos_clamp(ld x) { return x>1 ? 0 : x<-1 ? M_PI : std::isnan(x) ? 0 : acos(x); } @@ -589,18 +592,42 @@ EX transmatrix cspin(int a, int b, ld alpha) { return T; } +/** rotate by 90 degrees in the coordinates a, b */ +EX transmatrix cspin90(int a, int b) { + transmatrix T = Id; + T[a][a] = 0; T[a][b] = 1; + T[b][a] = -1; T[b][b] = 0; + return T; + } + +/** rotate by 180 degrees in the coordinates a, b */ +EX transmatrix cspin180(int a, int b) { + transmatrix T = Id; + T[a][a] = T[b][b] = -1; + return T; + } + /** rotate by alpha degrees in the XY plane */ EX transmatrix spin(ld alpha) { return cspin(0, 1, alpha); } +/** rotate by 90 degrees in the XY plane */ +EX transmatrix spin90() { return cspin90(0, 1); } + +/** rotate by 180 degrees in the XY plane */ +EX transmatrix spin180() { return cspin180(0, 1); } + +/** rotate by 270 degrees in the XY plane */ +EX transmatrix spin270() { return cspin90(1, 0); } + EX transmatrix random_spin3() { ld alpha2 = asin(randd() * 2 - 1); - ld alpha = randd() * 2 * M_PI; - ld alpha3 = randd() * 2 * M_PI; + ld alpha = randd() * TAU; + ld alpha3 = randd() * TAU; return cspin(0, 1, alpha) * cspin(0, 2, alpha2) * cspin(1, 2, alpha3); } EX transmatrix random_spin() { - if(WDIM == 2) return spin(randd() * 2 * M_PI); + if(WDIM == 2) return spin(randd() * TAU); else return random_spin3(); } @@ -1181,13 +1208,13 @@ EX ld hdist0(const shiftpoint& mh) { EX ld circlelength(ld r) { switch(cgclass) { case gcEuclid: - return 2 * M_PI * r; + return TAU * r; case gcHyperbolic: - return 2 * M_PI * sinh(r); + return TAU * sinh(r); case gcSphere: - return 2 * M_PI * sin(r); + return TAU * sin(r); default: - return 2 * M_PI * r; + return TAU * r; } } @@ -1378,12 +1405,12 @@ EX transmatrix spin_towards(const transmatrix Position, transmatrix& ori, const } T = rspintox(U); } - if(back < 0) T = T * spin(M_PI), alpha = -alpha; + if(back < 0) T = T * spin180(), alpha = -alpha; if(prod) { if(dir == 0) ori = cspin(2, 0, alpha); - if(dir == 2) ori = cspin(2, 0, alpha - M_PI/2), dir = 0; + if(dir == 2) ori = cspin(2, 0, alpha - 90._deg), dir = 0; } - if(dir) T = T * cspin(dir, 0, -M_PI/2); + if(dir) T = T * cspin(dir, 0, -90._deg); T = Position * T; return T; } @@ -1536,7 +1563,7 @@ EX ld geo_dist(const shiftpoint h1, const shiftpoint h2, flagtype prec IS(pNORMA EX ld geo_dist_q(const hyperpoint h1, const hyperpoint h2, flagtype prec IS(pNORMAL)) { auto d = geo_dist(h1, h2, prec); - if(elliptic && d > M_PI/2) return M_PI - d; + if(elliptic && d > 90._deg) return M_PI - d; return d; } @@ -1551,15 +1578,15 @@ EX hyperpoint lp_apply(const hyperpoint h) { EX hyperpoint smalltangent() { return xtangent(.1); } EX void cyclefix(ld& a, ld b) { - while(a > b + M_PI) a -= 2 * M_PI; - while(a < b - M_PI) a += 2 * M_PI; + while(a > b + M_PI) a -= TAU; + while(a < b - M_PI) a += TAU; } EX ld raddif(ld a, ld b) { ld d = a-b; if(d < 0) d = -d; - if(d > 2*M_PI) d -= 2*M_PI; - if(d > M_PI) d = 2 * M_PI-d; + if(d > TAU) d -= TAU; + if(d > M_PI) d = TAU-d; return d; } diff --git a/hypgraph.cpp b/hypgraph.cpp index ce594abe..b961c405 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -105,13 +105,13 @@ EX shiftmatrix minimize_point_value(shiftmatrix T, function 0 ? max(y * 0.012/0.015, M_PI/2 - (M_PI/2-y) * 0.066262/0.015708) : - min(y * 0.012/0.015, -M_PI/2 + (M_PI/2+y) * 0.066262/0.015708); + y > 0 ? max(y * 0.012/0.015, 90._deg - (90._deg-y) * 0.066262/0.015708) : + min(y * 0.012/0.015, -90._deg + (90._deg+y) * 0.066262/0.015708); - if(sphere && abs(theta) >= M_PI/2 - 1e-6) ; + if(sphere && abs(theta) >= 90._deg - 1e-6) ; else { for(int it=0; it<4; it++) { auto a = (sin_auto(2*theta) +2*theta - M_PI * sin_auto(y)); auto b = (2 + 2 * cos_auto(2*theta)); theta = theta - a / b; } } - y = M_PI * sin_auto(theta) / 2; + y = 90._deg * sin_auto(theta); x = x * cos_auto(theta); }); break; @@ -1192,7 +1192,7 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { ld d0 = hypot(x0, z0); if(md == mdAitoff || md == mdWinkelTripel) ; - else if(sphere) d = sqrt(2*(1 - cos(d))) * M_PI / 2; + else if(sphere) d = sqrt(2*(1 - cos(d))) * 90._deg; else d = sqrt(2*(cosh(d) - 1)) / 1.5; x = x0 * d / d0 / pconf.aitoff_parameter, y = z0 * d / d0; @@ -1270,13 +1270,10 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) { ld df, zf; hypot_zlev(zlev, d, df, zf); - // 4 pi / 2pi = M_PI - if(md == mdEquivolume) - d = pow(volume_auto(d), 1/3.) * pow(M_PI / 2, 1/3.); + d = pow(volume_auto(d), 1/3.) * pow(90._deg, 1/3.); else if(md == mdEquiarea && sphere) { - d = sqrt(2*(1 - cos(d))) * M_PI / 2; - //d = sin((d+90*degree)/2); + d = sqrt(2*(1 - cos(d))) * 90._deg; } else if(pmodel == mdEquiarea && hyperbolic) d = sqrt(2*(cosh(d) - 1)) / 1.5; @@ -1572,7 +1569,7 @@ EX transmatrix actualV(const heptspin& hs, const transmatrix& V) { if(WDIM == 3) return V; #if CAP_IRR if(IRREGULAR) - return V * spin(M_PI + 2 * M_PI / S7 * (hs.spin + irr::periodmap[hs.at].base.spin)); + return V * spin(M_PI + TAU / S7 * (hs.spin + irr::periodmap[hs.at].base.spin)); #endif #if CAP_ARCM if(arcm::in()) return V * spin(-arcm::current.triangles[arcm::id_of(hs.at)][hs.spin].first); @@ -1581,7 +1578,7 @@ EX transmatrix actualV(const heptspin& hs, const transmatrix& V) { if(bt::in()) return V; #endif if(kite::in()) return V; - return (hs.spin || !BITRUNCATED) ? V * spin(hs.spin*2*M_PI/hs.at->type + master_to_c7_angle()) : V; + return (hs.spin || !BITRUNCATED) ? V * spin(hs.spin*TAU/hs.at->type + master_to_c7_angle()) : V; } EX shiftmatrix actualV(const heptspin& hs, const shiftmatrix& V) { @@ -1800,14 +1797,14 @@ void hrmap::draw_all() { int qty = ceil(1. / pconf.sphere_spiral_multiplier); if(qty > 100) qty = 100; for(int i=-qty; i < qty; i++) - draw_at(centerover, cview(2 * M_PI * i)); + draw_at(centerover, cview(TAU * i)); } else { draw_at(centerover, cview()); if(vid.use_smart_range) for(int i=1;; i++) { int drawn = cells_drawn; - draw_at(centerover, cview(2 * M_PI * i)); - draw_at(centerover, cview(-2 * M_PI * i)); + draw_at(centerover, cview(TAU * i)); + draw_at(centerover, cview(-TAU * i)); if(drawn == cells_drawn) break; } } @@ -1879,7 +1876,7 @@ void hrmap_standard::draw_at(cell *at, const shiftmatrix& where) { shiftmatrix Vd; if(inforder::mixed()) { int d1 = gmod(hs.spin+d, c->type); - Vd = V * spin(-2*M_PI*d/c->type) * xpush(spacedist(c, d1)) * spin(M_PI); + Vd = V * spin(-TAU*d/c->type) * xpush(spacedist(c, d1)) * spin180(); } else Vd = V * cgi.heptmove[d]; @@ -1925,7 +1922,7 @@ EX void spinEdge(ld aspd) { int dir = down_is_forward ? 0 : 1; - V = cspin(2, dir, 90 * degree) * V; + V = cspin90(2, dir) * V; if(1) { dynamicval g(geometry, gSphere); @@ -1942,7 +1939,7 @@ EX void spinEdge(ld aspd) { vrhr::be_33(V); - V = cspin(dir, 2, 90 * degree) * V; + V = cspin90(dir, 2) * V; V = inverse(T) * V; if(!prod) V = V * gpushxto0(h); get_view_orientation() = V; @@ -2038,7 +2035,7 @@ EX void centerpc(ld aspd) { else View = iso_inverse(T); if(prod) NLP = ortho_inverse(pc->ori); - if(WDIM == 2) rotate_view( cspin(0, 1, M_PI) * cspin(2, 1, M_PI/2 + shmup::playerturny[id]) * spin(-M_PI/2) ); + if(WDIM == 2) rotate_view( cspin180(0, 1) * cspin(2, 1, 90._deg + shmup::playerturny[id]) * spin270() ); return; } #endif @@ -2160,7 +2157,7 @@ void addball(ld a, ld b, ld c) { void ballgeometry() { queuereset(mdPixel, PPR::CIRCLE); for(int i=0; i<60; i++) - addball(i * M_PI/30, 10, 0); + addball(TAU * i / 60, 10, 0); for(double d=10; d>=-10; d-=.2) addball(0, d, 0); for(double d=-10; d<=10; d+=.2) @@ -2198,15 +2195,15 @@ EX void resetview() { } if(GDIM == 2) View = spin(M_PI + vid.fixed_facing_dir * degree) * View; - if(GDIM == 3 && !prod) View = cspin(0, 2, M_PI/2) * View; - if(prod) NLP = cspin(0, 2, M_PI/2); + if(GDIM == 3 && !prod) View = cspin90(0, 2) * View; + if(prod) NLP = cspin90(0, 2); if(cheater && eqmatrix(View, lView) && !centering) { View = Id; static ld cyc = 0; - cyc += 90 * degree; + cyc += 90._deg; View = spin(cyc) * View; if(GDIM == 2) View = spin(M_PI + vid.fixed_facing_dir * degree) * View; - if(GDIM == 3 && !prod) View = cspin(0, 2, M_PI/2) * View; + if(GDIM == 3 && !prod) View = cspin90(0, 2) * View; } } else if(currentmap) { @@ -2435,7 +2432,7 @@ EX void draw_model_elements() { case mdThreePoint: { vid.linewidth *= 5; for(int i=0; i<=3; i++) { - hyperpoint h = xspinpush0(2*M_PI*i/3, pconf.twopoint_param); + hyperpoint h = xspinpush0(120._deg*i, pconf.twopoint_param); models::apply_orientation(h[1], h[0]); models::apply_orientation_yz(h[2], h[1]); curvepoint(h); @@ -2519,11 +2516,11 @@ void queuestraight(hyperpoint X, int style, color_t lc, color_t fc, PPR p) { ld mul1 = hypot(vid.xres, vid.yres) / hypot_d(2, H1); queuereset(mdPixel, p); - curvepoint(H0 + spin(M_PI/2) * H0 * mul0); - curvepoint(H0 - spin(M_PI/2) * H0 * mul0); - curvepoint(H1 + spin(M_PI/2) * H1 * mul1); - curvepoint(H1 - spin(M_PI/2) * H1 * mul1); - curvepoint(H0 + spin(M_PI/2) * H0 * mul0); + curvepoint(H0 + spin90() * H0 * mul0); + curvepoint(H0 - spin90() * H0 * mul0); + curvepoint(H1 + spin90() * H1 * mul1); + curvepoint(H1 - spin90() * H1 * mul1); + curvepoint(H0 + spin90() * H0 * mul0); queuecurve(shiftless(Id), lc, fc, p).flags |= POLY_ALWAYS_IN | POLY_FORCEWIDE; queuereset(pmodel, p); @@ -2562,7 +2559,7 @@ EX void draw_boundary(int w) { #endif if(elliptic && !among(pmodel, mdBand, mdBandEquidistant, mdBandEquiarea, mdSinusoidal, mdMollweide, mdCollignon)) - circle_around_center(M_PI/2, periodcolor, 0, PPR::CIRCLE); + circle_around_center(90._deg, periodcolor, 0, PPR::CIRCLE); int broken_coord = models::get_broken_coord(pmodel); if(broken_coord) { @@ -2617,7 +2614,7 @@ EX void draw_boundary(int w) { if(pmodel == mdBand && pconf.model_transition != 1) return; bool bndband = (among(pmodel, mdBand, mdMiller, mdGallStereographic, mdCentralCyl) ? hyperbolic : sphere); transmatrix T = spin(-pconf.model_orientation * degree); - ld right = M_PI/2 - 1e-5; + ld right = 90._deg - 1e-5; if(bndband) queuestraight(T * ypush0(hyperbolic ? 10 : right), 2, lc, fc, p); ld xperiod = elliptic ? fakeinf/2 : fakeinf; @@ -2640,7 +2637,7 @@ EX void draw_boundary(int w) { case mdHalfplane: if(hyperbolic && GDIM == 2) { - queuestraight(xspinpush0(-pconf.model_orientation * degree - M_PI/2, fakeinf), 1, lc, fc, p); + queuestraight(xspinpush0(-pconf.model_orientation * degree - 90._deg, fakeinf), 1, lc, fc, p); return; } break; @@ -2708,13 +2705,13 @@ EX void draw_boundary(int w) { ld alpha = M_PI - atan2(a[0], -a[1]); for(ld t=-1; t<=1; t += step) - curvepoint(xspinpush0(-M_PI/2 - t * alpha, mz)); + curvepoint(xspinpush0(-90._deg - t * alpha, mz)); } else { ld alpha = - atan2(a[0], -a[1]); for(ld t=-1; t<=1; t += step) - curvepoint(xspinpush0(+M_PI/2 - t * alpha, mz)); + curvepoint(xspinpush0(+90._deg - t * alpha, mz)); } queuecurve(shiftless(Id), lc, fc, p); @@ -3100,7 +3097,7 @@ EX hyperpoint lie_exp(hyperpoint h) { EX hyperpoint rel_log(shiftpoint h) { if(sl2) { optimize_shift(h); - ld cycles = floor(h.shift / (2*M_PI) + .5); + ld cycles = floor(h.shift / TAU + .5); hyperpoint h1 = unshift(h); ld choice = h1[2] * h1[2] - h1[0] * h1[0] - h1[1] * h1[1]; ld r, z; @@ -3108,7 +3105,7 @@ EX hyperpoint rel_log(shiftpoint h) { ld r = sqrt(choice); ld z = asin_clamp(r); if(h1[3] < 0) z = M_PI - z; - z += cycles * 2 * M_PI; + z += cycles * TAU; } else if(cycles || h1[3] < -1 || choice == 0) { /* impossible, or light-like */ @@ -3238,7 +3235,7 @@ EX void shift_view_towards(shiftpoint H, ld l) { EX void set_view(hyperpoint camera, hyperpoint forward, hyperpoint upward) { if(GDIM == 2) { View = gpushxto0(camera); - View = spin(90*degree) * spintox(View * upward) * View; + View = spin90() * spintox(View * upward) * View; return; } diff --git a/intra.cpp b/intra.cpp index 6424454c..33ffd89c 100644 --- a/intra.cpp +++ b/intra.cpp @@ -187,8 +187,8 @@ EX portal_data make_portal(cellwalker cw, int spin) { for(auto p: fac) id.v0 += p; id.v0 = normalize_flat(id.v0); hyperpoint h = normalize_flat(fac[0]); - id.T = cspin(0, 1, -90*degree) * spintox(gpushxto0(id.v0) * h) * gpushxto0(id.v0); - if((id.T * C0)[0] > 0) id.T = cspin(0, 1, 180*degree) * id.T; + id.T = cspin90(1, 0) * spintox(gpushxto0(id.v0) * h) * gpushxto0(id.v0); + if((id.T * C0)[0] > 0) id.T = spin180() * id.T; for(int i=0; i<3; i++) id.T[3][i] = id.T[i][3] = i==3; if(debug_portal & 128) for(int a=0; a<4; a++) { @@ -233,13 +233,13 @@ EX portal_data make_portal(cellwalker cw, int spin) { id.T = gpushxto0(id.v0); for(auto p: fac1) { if(abs((id.T * p)[2]) > 1e-3 && abs((id.T * p)[0]) < 1e-3) - id.T = cspin(2, 0, 90*degree) * id.T; + id.T = cspin90(2, 0) * id.T; if(abs((id.T * p)[2]) > 1e-3 && abs((id.T * p)[1]) < 1e-3) - id.T = cspin(2, 1, 90*degree) * id.T; + id.T = cspin90(2, 1) * id.T; } - if((id.T * C03)[2] > 0) id.T = cspin(2, 0, 180*degree) * id.T; - if(abs((id.T * removed)[0]) > 1e-2) id.T = cspin(0, 1, 90*degree) * id.T; - if((id.T * removed)[1] < -1e-2) id.T = cspin(0, 1, 180*degree) * id.T; + if((id.T * C03)[2] > 0) id.T = cspin180(2, 0) * id.T; + if(abs((id.T * removed)[0]) > 1e-2) id.T = cspin90(0, 1) * id.T; + if((id.T * removed)[1] < -1e-2) id.T = cspin180(0, 1) * id.T; vector v; geometry = gg; for(auto f: fac) v.push_back(id.to_poco(f)); @@ -254,7 +254,7 @@ EX portal_data make_portal(cellwalker cw, int spin) { else { id.kind = 0; id.v0 = project_on_triangle(fac[0], fac[1], fac[2]); - id.T = cpush(2, -hdist0(id.v0)) * cspin(2, 0, 90*degree) * spintox(id.v0); + id.T = cpush(2, -hdist0(id.v0)) * cspin90(2, 0) * spintox(id.v0); hyperpoint ctr = Hypc; for(auto p: fac) ctr += id.T*p; ctr = normalize(ctr); diff --git a/irregular.cpp b/irregular.cpp index c79aa879..108ab329 100644 --- a/irregular.cpp +++ b/irregular.cpp @@ -460,7 +460,7 @@ bool step(int delta) { ld dist = cgi.hcrossf / 2; ld dists[8]; for(int i=0; i>, vector>> make_walls() { hyperpoint dtop = meupush( 0, shf+t*up) * meuscale(rphi) * C0; hyperpoint dbottom = meupush( 0, shf-down) * meuscale(rphi) * C0; - hyperpoint dleftmid = (!kite) ? meupush(0, shf-down) * meuscale(rphi) * meupush(-1, down) * C0 : meupush(0, shf-down) * meuscale(rphi) * mspin(-36 * degree) * meupush(0, down - up) * C0; - hyperpoint drightmid = (!kite) ? meupush(0, shf-down) * meuscale(rphi) * meupush(1, down) * C0 : meupush(0, shf-down) * meuscale(rphi) * mspin(36 * degree) * meupush(0, down - up) * C0; + hyperpoint dleftmid = (!kite) ? meupush(0, shf-down) * meuscale(rphi) * meupush(-1, down) * C0 : meupush(0, shf-down) * meuscale(rphi) * mspin(-36._deg) * meupush(0, down - up) * C0; + hyperpoint drightmid = (!kite) ? meupush(0, shf-down) * meuscale(rphi) * meupush(1, down) * C0 : meupush(0, shf-down) * meuscale(rphi) * mspin(36._deg) * meupush(0, down - up) * C0; hyperpoint dcenter = meupush( 0, shf-up) * meuscale(rphi) * C0; @@ -247,12 +247,12 @@ struct hrmap_kite : hrmap { } void make_graphrules() { - pKite1 = meupush(-1, kite_center + 0) * mspin(108 * degree) * meuscale(rphi) * meupush(0, down - kite_center); - pKite2 = meupush(1, kite_center + 0) * mspin(-108 * degree) * meuscale(rphi) * meupush(0, down - kite_center); - pKite3 = meupush(0, kite_center - down) * mspin(36 * degree) * meuscale(rphi) * meupush(0, down - dart_center); + pKite1 = meupush(-1, kite_center + 0) * mspin(108._deg) * meuscale(rphi) * meupush(0, down - kite_center); + pKite2 = meupush(1, kite_center + 0) * mspin(-108._deg) * meuscale(rphi) * meupush(0, down - kite_center); + pKite3 = meupush(0, kite_center - down) * mspin(36._deg) * meuscale(rphi) * meupush(0, down - dart_center); pDart1 = meupush(0, dart_center-down) * meuscale(rphi) * meupush(0, down - kite_center); - pDart2 = meupush(-1, dart_center+0) * mspin((54 + 90) * degree) * meuscale(rphi) * meupush(0, down - dart_center); + pDart2 = meupush(-1, dart_center+0) * mspin(144._deg) * meuscale(rphi) * meupush(0, down - dart_center); ipKite1 = inverse(pKite1); ipKite2 = inverse(pKite2); diff --git a/mapeditor.cpp b/mapeditor.cpp index a161a216..b5add395 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -89,7 +89,7 @@ EX namespace mapeditor { int ll = ceil(360 * len); shiftmatrix W = V * rgpushxto0(s); for(int i=0; i<=ll; i++) - curvepoint(xspinpush0(360*degree*i/ll, radius)); + curvepoint(xspinpush0(TAU*i/ll, radius)); queuecurve(W, col, fill, PPR::LINE); } @@ -1979,18 +1979,18 @@ EX namespace mapeditor { } transmatrix T; if(front_config == eFront::equidistants) T = Id; - else if(front_config == eFront::const_x) T = cspin(2, 0, M_PI/2); - else if(front_config == eFront::const_y) T = cspin(2, 1, M_PI/2); + else if(front_config == eFront::const_x) T = cspin90(2, 0); + else if(front_config == eFront::const_y) T = cspin90(2, 1); else return; for(int i=0; i<4; i+=2) { for(int u=2; u<=20; u++) { PRING(d) { - curvepoint(T * xspinpush(M_PI*d/cgi.S42, u/20.) * zpush0(front_edit)); + curvepoint(T * xspinpush(d*cgi.S_step, u/20.) * zpush0(front_edit)); } queuecurve(d2, cols[i + (u%5 != 0)], 0, i < 2 ? PPR::LINE : PPR::SUPERLINE); } for(int d=0; dtype) != 0)], 0, i < 2 ? PPR::LINE : PPR::SUPERLINE); } } @@ -1999,11 +1999,11 @@ EX namespace mapeditor { for(int d=0; dtype) == 0) ? gridcolor : lightgrid; - queueline(d2 * C0, d2 * xspinpush0(M_PI*d/cgi.S42, 1), col, 4 + vid.linequality); + queueline(d2 * C0, d2 * xspinpush0(d*cgi.S_step, 1), col, 4 + vid.linequality); } for(int u=2; u<=20; u++) { PRING(d) { - curvepoint(xspinpush0(M_PI*d/cgi.S42, u/20.)); + curvepoint(xspinpush0(d*cgi.S_step, u/20.)); } queuecurve(d2, (u%5==0) ? gridcolor : lightgrid, 0, PPR::LINE); } @@ -2057,8 +2057,7 @@ EX namespace mapeditor { // total: rh2 - rh1 // 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; + cyclefix(x, 0); area += x; } } @@ -2440,7 +2439,7 @@ EX namespace mapeditor { } if(uni == 'a' && haveshape) { - mh = spin(2*M_PI*-ew.rotid/dsCur->rots) * mh; + mh = spin(TAU*-ew.rotid/dsCur->rots) * mh; if(ew.symid) mh = Mirror * mh; if(ew.pointid < 0 || ew.pointid >= isize(dsCur->list)) @@ -2462,7 +2461,7 @@ EX namespace mapeditor { if(i < 0 || i >= isize(dsCur->list)) return; - mh = spin(2*M_PI*-ew.rotid/dsCur->rots) * mh; + mh = spin(TAU*-ew.rotid/dsCur->rots) * mh; if(ew.symid) mh = Mirror * mh; if(uni == 'm' || uni == 'M') @@ -2839,7 +2838,7 @@ EX namespace mapeditor { shiftmatrix T = rgpushxto0(lstart); texture::where = lstartcell; for(int i=0; id[l].rots; r++) { for(int i=0; id[l].list); i++) { hyperpoint h = us->d[l].list[i]; - h = spin(360 * degree * r / us->d[l].rots) * h; + h = spin(TAU * r / us->d[l].rots) * h; for(int d=0; dd[l].sym) for(int i=isize(us->d[l].list)-1; i>=0; i--) { hyperpoint h = us->d[l].list[i]; h[1] = -h[1]; - h = spin(360 * degree * r / us->d[l].rots) * h; + h = spin(TAU * r / us->d[l].rots) * h; for(int d=0; d .1) circp *= 2; for(int j=0; jtype; i += sih.symmetries) { - shiftmatrix M2 = V * applyPatterndir(c, sih) * spin(2*M_PI*i/c->type); + shiftmatrix M2 = V * applyPatterndir(c, sih) * spin(TAU * i / c->type); if(j) M2 = M2 * Mirror; switch(holdmouse ? mousekey : 'd') { case 'c': @@ -3141,14 +3140,14 @@ EX namespace mapeditor { if(mouseout()) break; - shiftpoint P2 = V * spin(2*M_PI*a/ds.rots) * (b?Mirror*mh:mh); + shiftpoint P2 = V * spin(TAU * a / ds.rots) * (b?Mirror*mh:mh); queuestr(P2, 10, "x", 0xFF00FF); } if(isize(ds.list) == 0) return us; - shiftpoint Plast = V * spin(-2*M_PI/ds.rots) * (ds.sym?Mirror*ds.list[0]:ds.list[isize(ds.list)-1]); + shiftpoint Plast = V * spin(-TAU / ds.rots) * (ds.sym?Mirror*ds.list[0]:ds.list[isize(ds.list)-1]); int state = 0; int gstate = 0; double dist2 = 0; @@ -3157,14 +3156,14 @@ EX namespace mapeditor { for(int a=0; amaster_relative(centerover, true)); euclidean_spin = gpushxto0(euclidean_spin * C0) * euclidean_spin; hyperpoint h = inverse(euclidean_spin) * (C0 + (euc::eumove(gp::loc{1,0})*C0 - C0) * vpconf.spiral_x + (euc::eumove(gp::loc{0,1})*C0 - C0) * vpconf.spiral_y); - spiral_multiplier = cld(0, 2 * M_PI) / cld(h[0], h[1]); + spiral_multiplier = cld(0, TAU) / cld(h[0], h[1]); } if(centerover && !history::on) @@ -323,11 +323,11 @@ EX namespace models { initquickqueue(); queuereset(mdPixel, PPR::LINE); for(int a=-1; a<=1; a++) { - curvepoint(point2(-M_PI/2 * current_display->radius, a*current_display->radius)); - curvepoint(point2(+M_PI/2 * current_display->radius, a*current_display->radius)); + curvepoint(point2(-90._deg * current_display->radius, a*current_display->radius)); + curvepoint(point2(+90._deg * current_display->radius, a*current_display->radius)); queuecurve(shiftless(Id), forecolor, 0, PPR::LINE); - curvepoint(point2(a*current_display->radius, -M_PI/2*current_display->radius)); - curvepoint(point2(a*current_display->radius, +M_PI/2*current_display->radius)); + curvepoint(point2(a*current_display->radius, -90._deg * current_display->radius)); + curvepoint(point2(a*current_display->radius, +90._deg * current_display->radius)); queuecurve(shiftless(Id), forecolor, 0, PPR::LINE); } queuereset(vpconf.model, PPR::LINE); @@ -1035,7 +1035,7 @@ EX namespace models { "Here you can change this parameter.", 'b'); param_f(p.miller_parameter, sp+"miller"); param_f(p.loximuthal_parameter, sp+"loximuthal") - -> editable(-M_PI/2, M_PI/2, .1, "loximuthal parameter", + -> editable(-90._deg, 90._deg, .1, "loximuthal parameter", "Loximuthal is similar to azimuthal equidistant, but based on loxodromes (lines of constant geographic direction) rather than geodesics. " "The loximuthal projection maps (the shortest) loxodromes to straight lines of the same length, going through the starting point. " "This setting changes the latitude of the starting point.\n\n" diff --git a/netgen.cpp b/netgen.cpp index b51fa664..46276879 100644 --- a/netgen.cpp +++ b/netgen.cpp @@ -366,8 +366,8 @@ EX namespace netgen { printf("faza %d cell %d\n", faza, i); for(int e=0; e= 0 && !dragging) { @@ -756,7 +756,7 @@ EX namespace netgen { } if(uni == 's') { View = Id; - if(ctof(centerover)) View = spin(2 * M_PI * (rand() % 7) / 7) * View; + if(ctof(centerover)) View = spin(TAU * (rand() % 7) / 7) * View; playermoved = false; } else if(uni == 'c') { diff --git a/nonisotropic.cpp b/nonisotropic.cpp index bed84f9e..3646152f 100644 --- a/nonisotropic.cpp +++ b/nonisotropic.cpp @@ -784,14 +784,14 @@ EX namespace nilv { if(hypot_d(2, h) < 1e-6) return point3(h[0], h[1], h[2]); else if(side > 1e-6) { - wmin = 0, wmax = 2 * M_PI; + wmin = 0, wmax = TAU; } else if(side < -1e-6) { - wmin = - 2 * M_PI, wmax = 0; + wmin = - TAU, wmax = 0; } else return point3(h[0], h[1], 0); - ld alpha_total = h[0] ? atan(h[1] / h[0]) : M_PI/2; + ld alpha_total = h[0] ? atan(h[1] / h[0]) : 90._deg; ld b; if(abs(h[0]) > abs(h[1])) @@ -1578,14 +1578,14 @@ EX namespace product { if(twisted && i == c->type-1 && where[c].second == hybrid::csteps-1) { auto b = spins[where[c].first].first; transmatrix T = mscale(Id, cgi.plevel); - T = T * spin(2 * M_PI * b.spin / b.at->type); + T = T * spin(TAU * b.spin / b.at->type); if(b.mirrored) T = T * Mirror; return T; } if(twisted && i == c->type-2 && where[c].second == 0) { auto b = spins[where[c].first].second; transmatrix T = mscale(Id, -cgi.plevel); - T = T * spin(2 * M_PI * b.spin / b.at->type); + T = T * spin(TAU * b.spin / b.at->type); if(b.mirrored) T = T * Mirror; return T; } @@ -1799,7 +1799,7 @@ EX namespace slr { ld z = cr * (K - 1/SV/SV); - ld k = M_PI/2; + ld k = 90._deg; ld a = k / K; ld zw = xy * cr / sr; ld u = z * a; @@ -2572,7 +2572,7 @@ EX namespace stretch { res.push_back(point31(h[0] * a / d, h[1] * a / d, h[2] * a / d)); - a = a - 2 * M_PI; + a = a - TAU; res.push_back(point31(h[0] * a / d, h[1] * a / d, h[2] * a / d)); @@ -2583,7 +2583,7 @@ EX namespace stretch { ld a = atan2(h[2], h[3]); for(int it=-generations; it= 1 ? 0 : sqrt(1-rp*rp); return atan2(co * sin(a), cos(a)) - co * (1 - 1/SV/SV) * a; - - // while(a0 > M_PI) a0 -= 2 * M_PI; - // while(a0 < -M_PI) a0 += 2 * M_PI; }; for(int shift=-generations; shift ", vmin, " to ", vmax); - int cmin = ceil((vmin - seek) / 2 / M_PI); - int cmax = floor((vmax - seek) / 2 / M_PI); + int cmin = ceil((vmin - seek) / TAU); + int cmax = floor((vmax - seek) / TAU); for(int c = cmin; c <= cmax; c++) { - ld cseek = seek + c * 2 * M_PI; + ld cseek = seek + c * TAU; for(int it=0; it<40; it++) { diff --git a/passable.cpp b/passable.cpp index dfe6ef89..42d8a463 100644 --- a/passable.cpp +++ b/passable.cpp @@ -304,7 +304,7 @@ EX ld calcAirdir(cell *c) { for(int i=0; itype; i++) { cell *c2 = c->move(i); if(c2 && c2->monst == moAirElemental) { - return c->c.spin(i) * 2 * M_PI / c2->type; + return c->c.spin(i) * TAU / c2->type; } } for(int i=0; itype; i++) { @@ -315,7 +315,7 @@ EX ld calcAirdir(cell *c) { for(int i=0; itype; i++) { cell *c3 = c2->move(i); if(c3 && c3->monst == moAirElemental) { - return c2->c.spin(i) * 2 * M_PI / c3->type; + return c2->c.spin(i) * TAU / c3->type; } } } diff --git a/pattern2.cpp b/pattern2.cpp index 19009354..7ce5a26d 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -2717,7 +2717,7 @@ EX namespace linepatterns { ALLCELLS( if(is_master(c) && !euclid) for(int i=0; imaster->move(i) && c->master->move(i) < c->master) { - gridlinef(V, C0, xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), cgi.tessf), col, 2 + vid.linequality); + gridlinef(V, C0, xspinpush0(-TAU*i/S7 - master_to_c7_angle(), cgi.tessf), col, 2 + vid.linequality); } ) ); @@ -2726,7 +2726,7 @@ EX namespace linepatterns { ALLCELLS( if(is_master(c) && !euclid) for(int i=0; imaster->move(i) && way(c->master, i) && c->master->move(i)->dm4 == c->master->dm4) - gridlinef(V, C0, xspinpush0(-2*M_PI*i/S7 - master_to_c7_angle(), cgi.tessf), col, 2 + vid.linequality); + gridlinef(V, C0, xspinpush0(-TAU*i/S7 - master_to_c7_angle(), cgi.tessf), col, 2 + vid.linequality); ) ); @@ -2821,15 +2821,15 @@ EX namespace linepatterns { if(pseudohept(c) && (p/4 == 10 || p/4 == 8)) for(int i=0; imove(i) && emeraldval(c->move(i)) == p-4) { gridlinef(V, C0, tC0(cgi.heptmove[i]), col, 2 + vid.linequality); - gridlinef(V, C0, xspinpush0(-i * 2 * M_PI / S7, -hdist/2), col, 2 + vid.linequality); + gridlinef(V, C0, xspinpush0(-i * TAU / S7, -hdist/2), col, 2 + vid.linequality); } ) ); linepattern patPalacelike("firewall lines", 0xFF400000, stdhyp_only, ALLCELLS( if(pseudohept(c)) for(int i=0; i<7; i++) - gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(cgi.tessf/2), - ddspin(c,i,M_PI*9/7) * xpush0(cgi.tessf/2), + gridlinef(V, ddspin(c,i,A_PI*5/7) * xpush0(cgi.tessf/2), + ddspin(c,i,A_PI*9/7) * xpush0(cgi.tessf/2), col, 1 + vid.linequality); ) ); @@ -2840,8 +2840,8 @@ EX namespace linepatterns { cell *c1 = createMov(c, (i+3) % 7); cell *c2 = createMov(c, (i+4) % 7); if(polarb50(c1) != a && polarb50(c2) != a) - gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(cgi.tessf/2), - ddspin(c,i,M_PI*9/7) * xpush0(cgi.tessf/2), + gridlinef(V, ddspin(c,i,A_PI*5/7) * xpush0(cgi.tessf/2), + ddspin(c,i,A_PI*9/7) * xpush0(cgi.tessf/2), col, 1 + vid.linequality); } ) @@ -2871,8 +2871,8 @@ EX namespace linepatterns { heptagon *h2 = c->master->modmove(i-1); if(!h1 || !h2) continue; if(emeraldval(h1->c7)/4 == 8 && emeraldval(h2->c7)/4 == 8) - gridlinef(V, ddspin(c,i,M_PI*5/7) * xpush0(cgi.tessf/2), - ddspin(c,i,M_PI*9/7) * xpush0(cgi.tessf/2), + gridlinef(V, ddspin(c,i,A_PI*5/7) * xpush0(cgi.tessf/2), + ddspin(c,i,A_PI*9/7) * xpush0(cgi.tessf/2), col, 1 + vid.linequality); } ) @@ -2951,9 +2951,9 @@ EX namespace linepatterns { ) ); EX ld parallel_count = 6; - EX ld parallel_max = 90 * degree; - EX ld parallel_length = 180 * degree; - linepattern patParallels("parallels", 0xFFFFFF00, always_available, + EX ld parallel_max = 90._deg; + EX ld parallel_length = M_PI; + linepattern patParallels("parallels", 0xFFFFFF00, always_available, ATCENTER( for(int i=-int(parallel_count); i<=parallel_count; i ++) { ld phi = i * parallel_max / parallel_count; diff --git a/polygons.cpp b/polygons.cpp index 0133dc5b..f127cea1 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -18,8 +18,7 @@ static constexpr ld WOLF = (-15.5); void geometry_information::hpc_connect_ideal(hyperpoint a, hyperpoint b) { ld left = -atan2(a); ld right = -atan2(b); - if(right > left + 180*degree) right -= 360*degree; - if(right < left - 180*degree) right += 360*degree; + cyclefix(right, left); /* call hpc.push_back directly to avoid adding points */ ld qty = ceil(abs(right-left) / ideal_each); for(int i=0; i<=qty; i++) hpc.push_back(xspinpush0(lerp(left, right, i/qty), ideal_limit)); @@ -149,7 +148,7 @@ void geometry_information::extra_vertices() { #endif } -transmatrix geometry_information::ddi(int a, ld x) { return xspinpush(a * M_PI / S42, x); } +transmatrix geometry_information::ddi(int a, ld x) { return xspinpush(a * S_step, x); } void geometry_information::drawTentacle(hpcshape &h, ld rad, ld var, ld divby) { double tlength = max(crossf, hexhexdist); @@ -319,7 +318,7 @@ void geometry_information::bshape(hpcshape& sh, PPR prio, double shzoom, int sha } } else shzoomx *= bscale7, shzoomy *= bscale7; - double bonusf = /* sphere ? M_PI*4/35 : */ (rots-rots2+.0) / rots2; + double bonusf = (rots-rots2+.0) / rots2; auto ipoint = [&] (int i, int mul) { hyperpoint h = hpxy(polydata[whereis+2*i] * shzoomx, polydata[whereis+2*i+1] * shzoomy * mul); @@ -330,10 +329,10 @@ void geometry_information::bshape(hpcshape& sh, PPR prio, double shzoom, int sha for(int r=0; r=0; i--) - hpcpush(spin(2*M_PI*r/rots2) * ipoint(i, -1)); + hpcpush(spin(TAU*r/rots2) * ipoint(i, -1)); } hpcpush(ipoint(0, 1)); finishshape(); @@ -412,8 +411,8 @@ void geometry_information::make_sidewalls() { void geometry_information::procedural_shapes() { bshape(shMovestar, PPR::MOVESTAR); for(int i=0; i<=8; i++) { - hpcpush(xspinpush0(M_PI * i/4, crossf)); - if(i != 8) hpcpush(xspinpush0(M_PI * i/4 + M_PI/8, crossf/4)); + hpcpush(xspinpush0(90._deg * i, crossf)); + if(i != 8) hpcpush(xspinpush0(90._deg * i + 45._deg, crossf/4)); } // procedural floors @@ -525,7 +524,7 @@ void geometry_information::procedural_shapes() { bshape(shCross, PPR::WALL); for(int i=0; i<=84; i+=7) - hpcpush(xspinpush0(2*M_PI*i/84, zhexf * (i%3 ? 0.8 : 0.3))); + hpcpush(xspinpush0(TAU*i/84, zhexf * (i%3 ? 0.8 : 0.3))); // items @@ -634,8 +633,8 @@ void geometry_information::procedural_shapes() { bshape(shEccentricDisk, PPR::ITEM); for(int i=0; i<=S84; i+=SD3) { - hpcpush(hpxy(sin(i*2*M_PI/S84)*orbsize*.075, - cos(i*2*M_PI/S84)*orbsize*.075 + .07)); + hpcpush(hpxy(sin(i*S_step)*orbsize*.075, + cos(i*S_step)*orbsize*.075 + .07)); } bshape(shDiskSq, PPR::ITEM); @@ -645,11 +644,11 @@ void geometry_information::procedural_shapes() { bshape(shEgg, PPR::ITEM); RING(i) - hpcpush(hpxy(sin(i*2*M_PI/S84)*0.242 * orbsize, cos(i*2*M_PI/S84)*0.177*orbsize)); + hpcpush(hpxy(sin(i*S_step)*0.242 * orbsize, cos(i*S_step)*0.177*orbsize)); bshape(shSmallEgg, PPR::ITEM); RING(i) - hpcpush(hpxy(sin(i*2*M_PI/S84)*0.242 * orbsize/2, cos(i*2*M_PI/S84)*0.177*orbsize/2)); + hpcpush(hpxy(sin(i*S_step)*0.242 * orbsize/2, cos(i*S_step)*0.177*orbsize/2)); auto make_ring = [this] (hpcshape& sh, reaction_t f) { bshape(sh, PPR::ITEM); @@ -812,11 +811,11 @@ void geometry_information::procedural_shapes() { bshape(shSlime, PPR::MONSTER_BODY); PRING(i) - hpcpush(ddi(i, scalefactor * hcrossf7 * (0.7 + .2 * sin(i * M_PI * 2 / S84 * 9))) * C0); + hpcpush(ddi(i, scalefactor * hcrossf7 * (0.7 + .2 * sin(i * S_step * 9))) * C0); bshape(shJelly, PPR::MONSTER_BODY); PRING(i) - hpcpush(ddi(i, scalefactor * hcrossf7 * (0.4 + .03 * sin(i * M_PI * 2 / S84 * 7))) * C0); + hpcpush(ddi(i, scalefactor * hcrossf7 * (0.4 + .03 * sin(i * S_step * 7))) * C0); bshape(shHeptaMarker, PPR::HEPTAMARK); for(int t=0; t<=SD7; t++) hpcpush(ddi(t*S12, zhexf*.2) * C0); @@ -826,25 +825,25 @@ void geometry_information::procedural_shapes() { bshape(shRose, PPR::ITEM); PRING(t) - hpcpush(xspinpush0(M_PI * t / (S42+.0), scalefactor * hcrossf7 * (0.2 + .15 * sin(M_PI * t / (S42+.0) * 3)))); + hpcpush(xspinpush0(S_step * t, scalefactor * hcrossf7 * (0.2 + .15 * sin(S_step * t * 3)))); finishshape(); shRoseItem = shRose; bshape(shSmallRose, PPR::ITEM); PRING(t) - hpcpush(xspinpush0(M_PI * t / (S42+.0), scalefactor/2 * hcrossf7 * (0.2 + .15 * sin(M_PI * t / (S42+.0) * 3)))); + hpcpush(xspinpush0(S_step * t, scalefactor/2 * hcrossf7 * (0.2 + .15 * sin(S_step * t * 3)))); finishshape(); bshape(shThorns, PPR::THORNS); for(int t=0; t<=60; t++) - hpcpush(xspinpush0(M_PI * t / 30.0, scalefactor * hcrossf7 * ((t&1) ? 0.3 : 0.6))); + hpcpush(xspinpush0(TAU * t / 60, scalefactor * hcrossf7 * ((t&1) ? 0.3 : 0.6))); for(int i=0; i<16; i++) { bshape(shParticle[i], PPR::PARTICLE); for(int t=0; t<6; t++) // hpcpush(xspinpush0(M_PI * t * 2 / 6 + M_PI * 2/6 * hrand(100) / 150., (0.03 + hrand(100) * 0.0003) * scalefactor)); - hpcpush(xspinpush0(M_PI * t * 2 / 6 + M_PI * 2/6 * randd() / 1.5, (0.03 + randd() * 0.03) * scalefactor)); + hpcpush(xspinpush0(TAU * t / 6 + 60._deg * randd() / 1.5, (0.03 + randd() * 0.03) * scalefactor)); hpc.push_back(hpc[last->s]); } @@ -853,7 +852,7 @@ void geometry_information::procedural_shapes() { if(GDIM == 3) asteroid_size[i] *= 7; bshape(shAsteroid[i], PPR::PARTICLE); for(int t=0; t<12; t++) - hpcpush(xspinpush0(M_PI * t / 6, asteroid_size[i] * (1 - randd() * .2))); + hpcpush(xspinpush0(TAU * t / 12, asteroid_size[i] * (1 - randd() * .2))); hpc.push_back(hpc[last->s]); } @@ -1100,7 +1099,7 @@ void geometry_information::configure_floorshapes() { if(!BITRUNCATED) { ld hedge = hdist(xspinpush0(M_PI/S7, rhexf), xspinpush0(-M_PI/S7, rhexf)); - trihepta1 = hdist0(xpush(tessf) * xspinpush0(2*M_PI*2/S7, tessf)) / 2 * .98; + trihepta1 = hdist0(xpush(tessf) * xspinpush0(TAU*2/S7, tessf)) / 2 * .98; trihepta0 = hdist0(xpush(-tessf) * xspinpush0(M_PI/S7, rhexf+hedge/2)) * .98; } @@ -1150,6 +1149,7 @@ void geometry_information::prepare_shapes() { S28 = SD7 * 4; S36 = SD6 * 6; S84 = S42 * 2; + S_step = A_PI / S42; // printf("crossf = %f euclid = %d sphere = %d\n", float(crossf), euclid, sphere); hpc.clear(); ext.clear(); @@ -1179,11 +1179,11 @@ void geometry_information::prepare_shapes() { dynamicval d(vid.texture_step, max(vid.texture_step, 4)); ld len6 = hdist0(mid(xpush0(hexvdist), spin(M_PI/S3) * xpush0(hexvdist))); - ld len7 = hdist0(mid(xpush0(hexf), spin(M_PI*2/S7) * xpush0(hexf))); - ld hlen7 = hdist0(mid(xpush0(hcrossf), spin(M_PI*2/S7) * xpush0(hcrossf))); + ld len7 = hdist0(mid(xpush0(hexf), spin(TAU/S7) * xpush0(hexf))); + ld hlen7 = hdist0(mid(xpush0(hcrossf), spin(TAU/S7) * xpush0(hcrossf))); ld lenx = hdist(xpush0(hexvdist), spin(M_PI/S3) * xpush0(hexvdist)); - ld hlenx = hdist(xpush0(hcrossf), spin(2*M_PI/S7) * xpush0(hcrossf)); + ld hlenx = hdist(xpush0(hcrossf), spin(TAU/S7) * xpush0(hcrossf)); bshape(shHalfMirror[2], PPR::WALL); hpcpush(C0); hpcpush(xpush0(-len6*scalefactor)); chasmifyPoly(FLOOR, WALL, 0); diff --git a/racing.cpp b/racing.cpp index a32de41b..78109d48 100644 --- a/racing.cpp +++ b/racing.cpp @@ -54,10 +54,10 @@ EX int race_start_tick, race_finish_tick[MAXPLAYER]; typedef unsigned char uchar; uchar frac_to_uchar(ld x) { return uchar(x * 256); } -uchar angle_to_uchar(ld x) { return frac_to_uchar(x / 2 / M_PI); } +uchar angle_to_uchar(ld x) { return frac_to_uchar(x / TAU); } ld uchar_to_frac(uchar x) { return x / 256.; } -transmatrix spin_uchar(uchar x) { return spin(uchar_to_frac(x) * 2 * M_PI); } +transmatrix spin_uchar(uchar x) { return spin(uchar_to_frac(x) * TAU); } static const ld distance_multiplier = 4; @@ -763,7 +763,7 @@ EX bool set_view() { } at /= multi::players; at = normalize(at); - atm = rgpushxto0(at) * spin(-90*degree) * rspintox(gpushxto0(at) * first); + atm = rgpushxto0(at) * spin270() * rspintox(gpushxto0(at) * first); } if(racing::player_relative || quotient || (kite::in() && GDIM == 3)) { @@ -788,11 +788,11 @@ EX bool set_view() { View = xpush(-x) * T * iT1 * ypush(vid.yshift) * View; - if(GDIM == 3) View = cspin(2, 0, M_PI/2) * View; + if(GDIM == 3) View = cspin(2, 0, 90._deg) * View; fixmatrix(View); } if(GDIM == 3 && WDIM == 2) - View = cspin(0, 1, M_PI) * cspin(2, 1, M_PI/2 + shmup::playerturny[multi::cpid]) * spin(-M_PI/2) * View; + View = spin180() * cspin(2, 1, 90._deg + shmup::playerturny[multi::cpid]) * spin270() * View; else if(GDIM == 2) View = spin(race_angle * degree) * View; return true; } @@ -1348,7 +1348,7 @@ void draw_ghost(ghost& ghost) { shiftmatrix racerel(ld rel) { int bsize = vid.fsize * 2; - return shiftless(atscreenpos(bsize, vid.yres - bsize - rel * (vid.yres - bsize*2) / 100, bsize) * spin(M_PI/2)); + return shiftless(atscreenpos(bsize, vid.yres - bsize - rel * (vid.yres - bsize*2) / 100, bsize) * spin90()); } EX int get_percentage(cell *c) { diff --git a/radar.cpp b/radar.cpp index 19ea1b11..d18913ad 100644 --- a/radar.cpp +++ b/radar.cpp @@ -110,7 +110,7 @@ EX void draw_radar(bool cornermode) { curvepoint(atscreenpos(cx-cos(i * degree)*rad, cy-sin(i*degree)*rad, 1) * C0); queuecurve(sId, 0xFFFFFFFF, 0x000000FF, PPR::ZERO); - ld alpha = 15 * degree; + ld alpha = 15._deg; ld co = cos(alpha); ld si = sin(alpha); diff --git a/raycaster.cpp b/raycaster.cpp index dd2b6764..5524d8b0 100644 --- a/raycaster.cpp +++ b/raycaster.cpp @@ -2634,9 +2634,9 @@ EX void cast() { glUniformMatrix4fv(o->uStraighten, 1, 0, glhr::tmtogl_transpose(asonov::straighten).as_array()); } if(o->uReflectX != -1) { - auto h = glhr::pointtogl(tangent_length(spin(90*degree) * asonov::ty, 2)); + auto h = glhr::pointtogl(tangent_length(spin90() * asonov::ty, 2)); glUniform4fv(o->uReflectX, 1, &h[0]); - h = glhr::pointtogl(tangent_length(spin(90*degree) * asonov::tx, 2)); + h = glhr::pointtogl(tangent_length(spin90() * asonov::tx, 2)); glUniform4fv(o->uReflectY, 1, &h[0]); } #endif diff --git a/reg3.cpp b/reg3.cpp index b34e510f..c08c61bb 100644 --- a/reg3.cpp +++ b/reg3.cpp @@ -216,14 +216,14 @@ EX namespace reg3 { if(1) { dynamicval dg(geometry, gSphere); - angle_between_faces = edge_of_triangle_with_angles(2*M_PI/mid, M_PI/face, M_PI/face); + angle_between_faces = edge_of_triangle_with_angles(TAU/mid, M_PI/face, M_PI/face); h0 = xtangent(1); h1 = cspin(0, 1, angle_between_faces) * h0; - h2 = cspin(1, 2, 2*M_PI/face) * h1; - h3 = cspin(1, 2, -2*M_PI/face) * h1; + h2 = cspin(1, 2, TAU/face) * h1; + h3 = cspin(1, 2, -TAU/face) * h1; - hcrossf = edge_of_triangle_with_angles(M_PI/2, M_PI/mid, M_PI/face); + hcrossf = edge_of_triangle_with_angles(90._deg, M_PI/mid, M_PI/face); h012 = cspin(1, 2, M_PI/face) * cspin(0, 1, hcrossf) * h0; h013 = cspin(1, 2, -M_PI/face) * cspin(0, 1, hcrossf) * h0; @@ -245,7 +245,7 @@ EX namespace reg3 { u = normalize(u); hyperpoint h = C0 * face; - for(int i=0; i 2*M_PI) df -= 2*M_PI; - while(df > M_PI) df = 2*M_PI - df; - df /= 4*M_PI; + ld df = raddif(alpha[0], alpha[1]); + df /= 720._deg; wstats[d][0] += df; if(d==2) printf("df == %" PLDF " dd = %" PLDF "\n", df, dd); wstats[d][1] += df*dd; diff --git a/rogueviz/dhrg/loglik.cpp b/rogueviz/dhrg/loglik.cpp index 0d990f60..235eefa0 100644 --- a/rogueviz/dhrg/loglik.cpp +++ b/rogueviz/dhrg/loglik.cpp @@ -114,7 +114,7 @@ void origcoords() { using namespace rogueviz; vertexcoords.resize(N); for(int i=0; i 0 ? 1 : -1; y /= sy; ld z = 4. - 3. * (hyperbolic ? -sinh(y) : sin(y)); - x = 2. * x * sqrt(z / 6. / M_PI); - y = sy * sqrt(2*M_PI/3) * (2. - sqrt(z)); + x = 2. * x * sqrt(z / 1080._deg); + y = sy * sqrt(120._deg) * (2. - sqrt(z)); }); // https://en.wikipedia.org/wiki/Eckert_IV_projection @@ -109,7 +109,7 @@ void add_extra_projections() { cld theta = newton_inverse( [] (cld th) { return th + sin(th) * cos(th) + 2. * sin(th); }, [] (cld th) { return 1. + cos(th) * cos(th) - sin(th) * sin(th) + 2. * cos(th); }, - (2+M_PI/2) * sin(y), y); + (2+90._deg) * sin(y), y); static ld cox = 2 / sqrt(4*M_PI+M_PI*M_PI); static ld coy = 2 * sqrt(M_PI/(4+M_PI)); x = cox * x * (1. + cos(theta)); @@ -120,12 +120,12 @@ void add_extra_projections() { add_complex("Ortelius", 0, [] (cld& x, cld& y) { cld sx = (real(x)+imag(x)) > 0 ? 1 : -1; x /= sx; - if(abs(real(x)) < 90*degree) { + if(abs(real(x)) < 90._deg) { cld F = M_PI*M_PI / 8. / x + x / 2.; x = (x - F + sqrt(F*F-y*y)); } else { - x = sqrt(M_PI*M_PI/4 - y*y) + x - M_PI/2; + x = sqrt(M_PI*M_PI/4 - y*y) + x - 90._deg; } x *= sx; }); diff --git a/rogueviz/fifteen.cpp b/rogueviz/fifteen.cpp index 8d2de859..5d804d0f 100644 --- a/rogueviz/fifteen.cpp +++ b/rogueviz/fifteen.cpp @@ -64,7 +64,7 @@ void compute_triangle_markers() { println(hlog, triangle_markers); for(int i=0; iori); - NLP = hr::cspin(1, 2, 90 * degree) * spin(90 * degree) * NLP; + NLP = hr::cspin90(1, 2) * spin90() * NLP; if(NLP[0][2]) { auto downspin = -atan2(NLP[0][2], NLP[1][2]); @@ -245,9 +245,9 @@ namespace flocking { } } else { - View =spin(90 * degree) * View; + View =spin90() * View; if(GDIM == 3) { - View = hr::cspin(1, 2, 90 * degree) * View; + View = hr::cspin90(1, 2) * View; } shift_view(ztangent(follow_dist)); } diff --git a/rogueviz/functions.cpp b/rogueviz/functions.cpp index 4d07c66b..fa7ab75d 100644 --- a/rogueviz/functions.cpp +++ b/rogueviz/functions.cpp @@ -22,7 +22,7 @@ hyperpoint find_point(ld t) { exp_parser ep; auto &dict = ep.extra_params; dict["t"] = t; - dict["phi"] = t * 2 * M_PI; + dict["phi"] = t * TAU; dict["x"] = tan(t * M_PI - M_PI/2); for(auto& ff: formula) { ep.s = ff; diff --git a/rogueviz/fundamental.cpp b/rogueviz/fundamental.cpp index 8edc4e9e..3a3dc1cf 100644 --- a/rogueviz/fundamental.cpp +++ b/rogueviz/fundamental.cpp @@ -52,7 +52,7 @@ shiftmatrix labelpos(shiftpoint h1, shiftpoint h2) { shiftmatrix T = rgpushxto0(h); hyperpoint hx = inverse_shift(T, h2); ld alpha = atan2(-hx[1], hx[0]); - return T * xspinpush(alpha + M_PI/2, label_dist); + return T * xspinpush(alpha + 90._deg, label_dist); } ld widthfactor = 5; diff --git a/rogueviz/horo63.cpp b/rogueviz/horo63.cpp index 8eee4e8b..cd36b819 100644 --- a/rogueviz/horo63.cpp +++ b/rogueviz/horo63.cpp @@ -23,7 +23,7 @@ bool draw_horo63(cell *c, const shiftmatrix& V) { array c; hyperpoint ctr; for(int i=0; i<6; i++) { - hyperpoint h = spin(60*degree*i) * point31(1,0,0); + hyperpoint h = spin(TAU*i/6) * point31(1,0,0); h[0] += x; h[0] += y/2.; h[1] += sqrt(3)/2. * y; diff --git a/rogueviz/hypcity.cpp b/rogueviz/hypcity.cpp index dc4ac19f..6d170da9 100644 --- a/rogueviz/hypcity.cpp +++ b/rogueviz/hypcity.cpp @@ -55,7 +55,7 @@ void prepare_tf() { hx[1] = h[1] * t * 2; hx[2] = 0; hx[3] = 1; - if(hyperbolic) hx = spin(45 * degree) * hx; + if(hyperbolic) hx = spin(45._deg) * hx; hx = normalize(hx); hx = zshift(hx, h[2]*(t*(sphere ? 3 : 7))); diff --git a/rogueviz/hyperbolic-analogs.cpp b/rogueviz/hyperbolic-analogs.cpp index 052c7368..8c3afc44 100644 --- a/rogueviz/hyperbolic-analogs.cpp +++ b/rogueviz/hyperbolic-analogs.cpp @@ -29,7 +29,7 @@ vector models_to_use = { pmodel = mdDisk; pconf.alpha = 1000; pconf.scale *= pconf.alpha; - View = cspin(1, 2, 20 * degree) * View; + View = cspin(1, 2, 20._deg) * View; } else { pmodel = mdHyperboloid; @@ -112,7 +112,7 @@ vector models_to_use = { pconf.scale = .5; if(sphere) pconf.scale *= 2; spherename = "loximuthal projection"; - pconf.loximuthal_parameter = 15 * degree; + pconf.loximuthal_parameter = 15._deg; }, [] { pmodel = mdSinusoidal; @@ -276,13 +276,13 @@ EX void compare() { if(at4 == 0) earthpart = lerp(255, earthpart, t4); else if(at4 == 1) - View = spin(t4 * 180 * degree) * View; + View = spin(t4 * M_PI) * View; else if(at4 == 2) - View = xpush(t4 * M_PI) * spin(M_PI) * View; + View = xpush(t4 * M_PI) * spin180() * View; else if(at4 == 3) - View = ypush(t4 * M_PI) * xpush(M_PI) * spin(M_PI) * View; + View = ypush(t4 * M_PI) * xpush(M_PI) * spin180() * View; else if(at4 == 4) { - View = ypush(M_PI) * xpush(M_PI) * spin(M_PI) * View; + View = ypush(M_PI) * xpush(M_PI) * spin180() * View; earthpart = lerp(255, earthpart, 1-t4); } anims::moved(); diff --git a/rogueviz/hyperbolic-minesweeper-pres.cpp b/rogueviz/hyperbolic-minesweeper-pres.cpp index 4f05ffec..4eb2dba8 100644 --- a/rogueviz/hyperbolic-minesweeper-pres.cpp +++ b/rogueviz/hyperbolic-minesweeper-pres.cpp @@ -76,7 +76,7 @@ vector cl_sphere() { vector lst; auto all = currentmap->allcells(); for(cell *c: all) { - hyperpoint h = spin(45*degree) * currentmap->relative_matrix(c, cs.at, C0) * C0; + hyperpoint h = spin(45._deg) * currentmap->relative_matrix(c, cs.at, C0) * C0; if(-h[2] < max(abs(h[0]), abs(h[1]))) { lst.push_back(c); } @@ -266,9 +266,9 @@ void mine_slide(tour::presmode mode, reaction_t set_geom, function cwt.at = centerover = starter; View = Id; if(hyperbolic) - View = spin(45*degree) * View; + View = spin(45._deg) * View; if(sphere) { - View = spin(45*degree) * View; + View = spin(45._deg) * View; slide_backup(pconf.scale, 1000); slide_backup(pconf.alpha, 1000); slide_backup(modelcolor, 0xFF); @@ -343,7 +343,7 @@ void enable_earth() { texture::config.color_alpha = 255; mapeditor::drawplayer = false; fullcenter(); - View = spin(4 * M_PI / 5 + M_PI / 2) * View; + View = spin(234._deg) * View; } slide sweeper_slides[] = { @@ -515,10 +515,10 @@ slide sweeper_slides[] = { enable_earth(); View = Id; - View = spin(3 * M_PI / 5) * View; - View = spin(90*degree) * View; - View = cspin(2, 0, 45 * degree) * View; - View = cspin(1, 2, 30 * degree) * View; + View = spin(108._deg) * View; + View = spin(90._deg) * View; + View = cspin(2, 0, 45._deg) * View; + View = cspin(1, 2, 30._deg) * View; playermoved = false; tour::slide_backup(vid.axes, 0); tour::slide_backup(vid.drawmousecircle, false); @@ -569,7 +569,7 @@ slide sweeper_slides[] = { start_game(); tour::slide_backup(vid.use_smart_range, 2); tour::slide_backup(vid.smart_range_detail, 1); - View = spin(90*degree); + View = spin90(); using linepatterns::patTree; tour::slide_backup(patTree.color, 0); } @@ -847,7 +847,7 @@ slide sweeper_slides[] = { start_game(); tour::slide_backup(vid.use_smart_range, 2); tour::slide_backup(vid.smart_range_detail, 1); - View = spin(90*degree); + View = spin90(); using linepatterns::patTree; tour::slide_backup(patTree.color, 0); } diff --git a/rogueviz/hypocycloid.cpp b/rogueviz/hypocycloid.cpp index fe19fbf2..16f37518 100644 --- a/rogueviz/hypocycloid.cpp +++ b/rogueviz/hypocycloid.cpp @@ -72,9 +72,9 @@ void circ_frame() { shiftmatrix at = ggmatrix(cwt.at) * xpush(xdist); - ld kdegree = 2 * M_PI / prec; + ld kdegree = TAU / prec; - ld cs = 2*M_PI*cshift; + ld cs = TAU * cshift; if(shape) { auto shapefun = [&] (ld x) { diff --git a/rogueviz/impossible-ring.cpp b/rogueviz/impossible-ring.cpp index 19c0c8d2..3d86110d 100644 --- a/rogueviz/impossible-ring.cpp +++ b/rogueviz/impossible-ring.cpp @@ -61,12 +61,12 @@ struct iring { ld delta = 0.004; - transmatrix T = cspin(1, 2, 45*degree); + transmatrix T = cspin(1, 2, 45._deg); int switchat = nil ? 1024 : 2048; auto step = [&] (int id) { - ld alpha = id * 1. / steps * 2 * M_PI; + ld alpha = id * 1. / steps * TAU; if(id < switchat) return T * point3(cos(alpha) * delta, sin(alpha) * delta, 0); else @@ -113,7 +113,7 @@ struct iring { hyperpoint uds[3]; - ld alpha = a * 1. / steps * 2 * M_PI; + ld alpha = a * 1. / steps * TAU; if(a < switchat) { uds[0] = T * point31(sin(alpha) * cscale, -cos(alpha) * cscale, 0) - C0; uds[1] = T * point31(0, 0, cscale) - C0; diff --git a/rogueviz/intra-demos.cpp b/rogueviz/intra-demos.cpp index 1f4b7386..11c1d74b 100644 --- a/rogueviz/intra-demos.cpp +++ b/rogueviz/intra-demos.cpp @@ -237,7 +237,7 @@ void create_intra_120() { hyperpoint h = currentmap->get_corner(s, 1); for(cell *c: currentmap->allcells()) { hyperpoint j = currentmap->relative_matrix(c, s, C0) * C0; - if(hdist(h, j) > M_PI/2) c->wall = waPalace; + if(hdist(h, j) > 90._deg) c->wall = waPalace; } for(cell *c: currentmap->allcells()) if(c->wall == waPalace) { int nei = 0; @@ -277,7 +277,7 @@ void create_intra_1440() { for(cell *c: currentmap->allcells()) { hyperpoint j = currentmap->relative_matrix(c, s, C0) * C0; // hyperpoint j = inverse(currentmap->relative_matrix(cwt.at, c, C0)) * C0; - if(hdist(h, j) > M_PI/2) + if(hdist(h, j) > 90._deg) set_wall(c, (celldistance(c, s)&1) ? 0xFF80FF : 0xFF00FF); } } diff --git a/rogueviz/magmahep.cpp b/rogueviz/magmahep.cpp index 6b45175d..b5a7eee0 100644 --- a/rogueviz/magmahep.cpp +++ b/rogueviz/magmahep.cpp @@ -58,7 +58,7 @@ void make() { /* compute the vertices */ vertices.resize(magmav+1); for(int i=0; i<=magmav; i++) - vertices[i] = spin(2*M_PI*(i+(v-7)/4.)/v) * xpush0(1); + vertices[i] = spin(TAU*(i+(v-7)/4.)/v) * xpush0(1); ld xx = vertices[2][0]; int down = v/2 + 2; @@ -196,7 +196,7 @@ void draw_at(transmatrix T, color_t col, int id) { if(magmadebug) { for(int i=0; i cgl(vid.cells_generated_limit, 9999999); dynamicval cdl(vid.cells_drawn_limit, 9999999); dynamicval r(mousing, false); @@ -629,7 +629,7 @@ void draw_ncee() { period = 2 * hdist0(tC0(currentmap->adj(cwt.at, 0))); } - period *= 2 / M_PI; + period /= 90._deg; dynamicval pm(pmodel, mdPixel); dynamicval pg(geometry, gEuclid); @@ -919,7 +919,7 @@ void ncee() { if(uni == 'X') { int D = 100; - fmap = genellipse(D, -10 * degree), reset_vxy(); + fmap = genellipse(D, -10._deg), reset_vxy(); #if CAP_NCONF nconf_solve(); #endif diff --git a/rogueviz/nilrider/level.cpp b/rogueviz/nilrider/level.cpp index f6513256..8ca09f66 100644 --- a/rogueviz/nilrider/level.cpp +++ b/rogueviz/nilrider/level.cpp @@ -219,8 +219,8 @@ void level::init_shapes() { if(bmch == 'f' && (x&1) && (y&1)) { for(int s=0; s<4; s++) { hyperpoint st = point3(x+.1, y+.1, 0); - hyperpoint a = spin(90*degree*s) * point3(.1, .1, 0); - hyperpoint b = spin(90*degree*(s+1)) * point3(.1, .1, 0); + hyperpoint a = spin(90._deg*s) * point3(.1, .1, 0); + hyperpoint b = spin(90._deg*(s+1)) * point3(.1, .1, 0); hyperpoint hi = point3(0, 0, 1); for(int z=0; z<3; z++) { ld z1 = (3-z) / 3.; @@ -252,8 +252,8 @@ void level::init_shapes() { ld need = safe_alt(ctr, -1) / scale / scale; int max_y = need * 2 + 1; - hyperpoint a = spin(90*degree*s) * point3(1, 0, 0); - hyperpoint b = spin(90*degree*s) * point3(0, 1, 0); + hyperpoint a = spin(90._deg*s) * point3(1, 0, 0); + hyperpoint b = spin(90._deg*s) * point3(0, 1, 0); auto pt = [&] (ld af, ld bf, ld yf) { hyperpoint ha = a * af * scale; ha[3] = 1; @@ -402,12 +402,12 @@ void level::init() { dynamicval lop1(loaded_or_planned, true); dynamicval lop2(planning_mode, false); if(c.tick(this) == b) break; - start.heading_angle -= 1 * degree; + start.heading_angle -= degree; } if(flags & nrlOrder) { sort(triangles.begin(), triangles.end(), [this] (triangledata a, triangledata b) { - return atan2(spin(120*degree)*(a.where - start.where)) < atan2(spin(120*degree)*(b.where - start.where)); + return atan2(spin(120._deg)*(a.where - start.where)) < atan2(spin(120._deg)*(b.where - start.where)); }); for(auto t: triangles) println(hlog, t.where); } @@ -419,8 +419,7 @@ xy_float level::get_xy_f(hyperpoint h) { if(flags & nrlPolar) { tie(h[0], h[1]) = make_pair(atan2(h[0], h[1]), hypot(h[0], h[1])); ld bar = (minx + maxx) / 2; - while(h[0] < bar - M_PI) h[0] += 2 * M_PI; - while(h[0] > bar + M_PI) h[0] -= 2 * M_PI; + cyclefix(h[0], bar); } int tY = isize(map_tiles); int tX = isize(map_tiles[0]); @@ -455,7 +454,7 @@ hyperpoint level::mappt(ld x, ld y, int s) { }; void level::init_plan() { - plan.emplace_back(start.where, hpxy(cos(start.heading_angle + 90*degree) * 2, sin(start.heading_angle + 90*degree) * 2)); + plan.emplace_back(start.where, hpxy(cos(start.heading_angle + 90._deg) * 2, sin(start.heading_angle + 90._deg) * 2)); current = start; } diff --git a/rogueviz/nilrider/levels.cpp b/rogueviz/nilrider/levels.cpp index 9b569322..9b443915 100644 --- a/rogueviz/nilrider/levels.cpp +++ b/rogueviz/nilrider/levels.cpp @@ -62,7 +62,7 @@ ld geodesics_0(hyperpoint h) { ld r = hypot_d(2, h); ld phi = atan2(h[1], h[0]); - ld z = (phi / 2 / M_PI) * (M_PI * r * r + 2 * M_PI); + ld z = (phi / TAU) * (M_PI * r * r + TAU); return z + rot_plane(h); } @@ -70,7 +70,7 @@ ld geodesics_at_4(hyperpoint h) { ld r = 4; ld phi = atan2(h[1], h[0]); - ld z = (phi / 2 / M_PI) * (M_PI * r * r + 2 * M_PI); + ld z = (phi / TAU) * (M_PI * r * r + TAU); return z + rot_plane(h); } @@ -381,7 +381,7 @@ level geodesical( "light rays are assumed to be geodesics.\n\n" "Geodesics in Nil are horizontal, vertical, and helical. " "In this level, all the roads are (fragments of) helical geodesics.", - -45*degree, 3*dft_block, 225*degree, 0, + -45._deg, 3*dft_block, 225._deg, 0, // -8*dft_block, +8*dft_block, +8*dft_block, 0, { "ffffffffffffffff", @@ -404,7 +404,7 @@ level geodesical( level geodesical4( "Helical Geodesic", 's', nrlPolar, "The main road here is a helical geodesic. Orthogonal lines are horizontal.", - -80*degree, 8.5*dft_block, 260*degree, 0.5*dft_block, + -80._deg, 8.5*dft_block, 260._deg, 0.5*dft_block, // -8*dft_block, +8*dft_block, +8*dft_block, 0, { "!!!!!!!!!!!!!!!!", @@ -560,10 +560,9 @@ struct complex_surface { auto d = hypot_d(2, h1); ld r = 2; h1 = h1 * (r / d); - ld phi = atan2(h1[1], h1[0]) + 90*degree; - ld phis = atan2((start-ctr)[1], (start-ctr)[0]) + 90 * degree; - if(phi < phis-M_PI) phi += 2 * M_PI; - if(phi > phis+M_PI) phi -= 2 * M_PI; + ld phi = atan2(h1[1], h1[0]) + 90._deg; + ld phis = atan2((start-ctr)[1], (start-ctr)[0]) + 90._deg; + cyclefix(phi, phis); h1 += ctr; auto z = [&] (ld a) { return point31(r*sin(a), -r*cos(a), (r * r / 2) * (a-sin(a)*cos(a))); }; @@ -577,11 +576,11 @@ struct complex_surface { hyperpoint h2 = h; if(start[0] == ctr[0]) h2[1] = start[1]; else h2[0] = start[0]; hyperpoint pre = rgpushxto0(start) * flatpush(h2-start) * flatpush(h-h2) * C0; - hyperpoint last = rgpushxto0(start) * gpushxto0(z(phis)) * rgpushxto0(z(phis + dir * 90*degree)) * C0; + hyperpoint last = rgpushxto0(start) * gpushxto0(z(phis)) * rgpushxto0(z(phis + dir * 90._deg)) * C0; hyperpoint h3 = h; if(start[0] != ctr[0]) h3[1] = last[1]; else h3[0] = last[0]; hyperpoint post = rgpushxto0(last) * flatpush(h3-last) * flatpush(h-h3) * C0; - ld p = (1+sin((phi-phis)*2 - 90*degree)) / 2.; + ld p = (1+sin((phi-phis)*2 - 90._deg)) / 2.; pre[2] = pre[2] + (post[2] - pre[2]) * p; diff --git a/rogueviz/nilrider/nilrider.cpp b/rogueviz/nilrider/nilrider.cpp index ceec52a5..13403d95 100644 --- a/rogueviz/nilrider/nilrider.cpp +++ b/rogueviz/nilrider/nilrider.cpp @@ -104,8 +104,8 @@ bool turn(int delta) { } #endif - if(min_gfx_slope < -90*degree) min_gfx_slope = -90*degree; - if(min_gfx_slope > +90*degree) min_gfx_slope = +90*degree; + if(min_gfx_slope < -90._deg) min_gfx_slope = -90._deg; + if(min_gfx_slope > +90._deg) min_gfx_slope = +90._deg; backing = false; @@ -659,7 +659,7 @@ auto celldemo = arg::add3("-unilcycle", initialize) + arg::add3("-unilplan", [] ->editable(0, 5, 0.05, "camera distance", "how far is the unicycle from the camera", 'd') ->set_reaction([] { curlev->current.centerview(curlev); }); param_f(min_gfx_slope, "min_gfx_slope") - ->editable(-90*degree, 90*degree, degree, "min camera slope", "affected by up/down", 'm'); + ->editable(-90._deg, 90._deg, degree, "min camera slope", "affected by up/down", 'm'); }) + arg::add3("-fullsim", [] { /* for animations */ diff --git a/rogueviz/nilrider/nilrider.h b/rogueviz/nilrider/nilrider.h index 867f7389..d0c96cb7 100644 --- a/rogueviz/nilrider/nilrider.h +++ b/rogueviz/nilrider/nilrider.h @@ -200,7 +200,7 @@ inline ld gravity = 1 / 16.; inline ld whdist = 0.5; /** minimum slope for rendering */ -inline ld min_gfx_slope = +M_PI/2; +inline ld min_gfx_slope = +90._deg; /** current slope for rendering */ inline ld gfx_slope = 0; diff --git a/rogueviz/nilrider/statues.cpp b/rogueviz/nilrider/statues.cpp index 47a01eba..c0a5b513 100644 --- a/rogueviz/nilrider/statues.cpp +++ b/rogueviz/nilrider/statues.cpp @@ -95,8 +95,8 @@ bool closed_grid(int x, int y) { template void add_statue(const T1& grid, const T2& f) { auto pt = [&] (int x, int y) { - ld x1 = x * M_PI / 16.; - ld y1 = y * M_PI / 32.; + ld x1 = x * TAU / 32; + ld y1 = y * TAU / 64; cgi.hpcpush(f(x1,y1)); }; for(int y=-16; y<16; y++) @@ -130,7 +130,7 @@ void init_statues() { for(int i=0; i<8; i++) { hyperpoint z = point31(0, 1e-6, 8); hyperpoint ih = inverse_exp(shiftless(z)); - ih = spin(i * 45 * degree) * ih; + ih = spin(i * TAU / 8) * ih; add_statue(closed_grid, [&] (ld lon, ld lat) { lat = lat * .75; hyperpoint h = direct_exp(ih * (.5 + lat / M_PI)); @@ -141,7 +141,7 @@ void init_statues() { cgi.extra_vertices(); cgi.add_texture(shGeostatue); - for(ld z: vector {M_PI/2+1e-2, M_PI+1e-2, M_PI*2+1e-2, 7, 10}) + for(ld z: vector {90._deg+1e-2, M_PI+1e-2, TAU+1e-2, 7, 10}) for(hyperpoint h: {point31(0, 0, z), point31(1e-3, 0, z), point31(1e-6, 0, z), point31(0, 1e-6, z)}) { hyperpoint i = inverse_exp(shiftless(h)); println(hlog, i, " @ ", hypot_d(3, i)); diff --git a/rogueviz/nilrider/timestamp.cpp b/rogueviz/nilrider/timestamp.cpp index b8fb06ee..d18f0be0 100644 --- a/rogueviz/nilrider/timestamp.cpp +++ b/rogueviz/nilrider/timestamp.cpp @@ -25,7 +25,7 @@ void timestamp::draw_unilcycle(const shiftmatrix& V) { hyperpoint base = Ta * Tb * point31(0, 0, whrad); for(int a=0; aallcells()) { int id = arcm::id_of(c->master); if(among(id, 0, 1)) for(int d=0; d hts; for(int i=0; i<3; i++) hts[i] = T * ts[i] * C0; @@ -213,12 +213,12 @@ void create_model() { hyperpoint chk = ts[0] * xspinpush0(alpha, h); mts[0] = chk; - mts[1] = spin(-2*M_PI/v) * chk; + mts[1] = spin(-TAU/v) * chk; mts[2] = matrix2 * chk; hyperpoint c[5]; for(int i=0; i<5; i++) - c[i] = hpxy(sin(2 * i * M_PI/5), cos(2 * i * M_PI/5)); + c[i] = hpxy(sin(i * TAU/5), cos(i * TAU/5)); hyperpoint tria[5]; tria[0] = mts[0]; @@ -256,7 +256,7 @@ void create_model() { // printf("createmodel with ticks = %d\n", ticks); - transmatrix t = hyperbolic ? hr::cspin(0, 2, M_PI) * xpush(sin(ticks * M_PI * 2 / anims::period)) : hr::cspin(0, 2, ticks * M_PI * 2 / anims::period); + transmatrix t = hyperbolic ? hr::cspin180(0, 2) * xpush(sin(ticks * TAU / anims::period)) : hr::cspin(0, 2, ticks * TAU / anims::period); hyperpoint hs = hyperbolic ? hpxyz(0,0,-1) : hpxyz(0,0,0); diff --git a/rogueviz/pentaroll.cpp b/rogueviz/pentaroll.cpp index 6375c899..d0791c17 100644 --- a/rogueviz/pentaroll.cpp +++ b/rogueviz/pentaroll.cpp @@ -112,7 +112,7 @@ void animate() { /* set_view does not orient correctly, so we rotate it */ - View = cspin(2, 0, M_PI/2) * View; + View = cspin90(2, 0) * View; /* we move the camera backward */ diff --git a/rogueviz/plane-immersion.cpp b/rogueviz/plane-immersion.cpp index 3d142308..9da6dfdd 100644 --- a/rogueviz/plane-immersion.cpp +++ b/rogueviz/plane-immersion.cpp @@ -19,8 +19,8 @@ color_t gridcol = 0xFFFFFFFF; hyperpoint fp(ld x, ld y) { x *= scale; y *= scale; - x *= M_PI/10 * sqrt(2)/2; - y *= M_PI/10 * sqrt(2)/2; + x *= A_PI/10 * sqrt(2)/2; + y *= A_PI/10 * sqrt(2)/2; if(euclid) return hyperpoint(x, y, 0, 1); @@ -28,12 +28,12 @@ hyperpoint fp(ld x, ld y) { ld a = sqrt(2)/2; x /= a; y /= a; - hyperpoint h = cspin(2, 3, -M_PI/4) * hyperpoint(sin(x)*a, sin(y)*a, cos(x)*a, cos(y)*a); + hyperpoint h = cspin(2, 3, -45._deg) * hyperpoint(sin(x)*a, sin(y)*a, cos(x)*a, cos(y)*a); return h; } if(hyperbolic) - return cspin(0, 2, -M_PI/2) * tC0(parabolic13(x, y)); + return cspin90(2, 0) * tC0(parabolic13(x, y)); if(nil) return hyperpoint(0, y, x, 1); @@ -45,7 +45,7 @@ hyperpoint fp(ld x, ld y) { ld a = sqrt(2)/2; x /= a; y /= a; - hyperpoint h = cspin(2, 3, -M_PI/4) * hyperpoint(sinh(x)*a, sinh(y)*a, cosh(x)*a, cosh(y)*a); + hyperpoint h = cspin(2, 3, -45._deg) * hyperpoint(sinh(x)*a, sinh(y)*a, cosh(x)*a, cosh(y)*a); return h; } @@ -90,16 +90,16 @@ void relocate() { vid.fixed_yz = false; - if(nil) rotate_view(cspin(2, 0, M_PI/2)); - if(prod) rotate_view(cspin(1, 2, M_PI/2)); + if(nil) rotate_view(cspin90(2, 0)); + if(prod) rotate_view(cspin90(1, 2)); if(emba == 1) { - rotate_view(cspin(0, 1, M_PI/4)); - rotate_view(cspin(1, 2, M_PI/6)); + rotate_view(cspin(0, 1, 45._deg)); + rotate_view(cspin(1, 2, 30._deg)); } if(emba == 2) { - rotate_view(cspin(1, 2, M_PI/2 * .9)); + rotate_view(cspin(1, 2, 81._deg)); } for(int a=0; a<100; a++) diff --git a/rogueviz/planets.cpp b/rogueviz/planets.cpp index ddf20f9c..49ce418d 100644 --- a/rogueviz/planets.cpp +++ b/rogueviz/planets.cpp @@ -239,7 +239,7 @@ ld prec = 5; void draw_earth() { load_planets(); - shiftmatrix S = ggmatrix(currentmap->gamestart()) * spin(90*degree); + shiftmatrix S = ggmatrix(currentmap->gamestart()) * spin90(); ld mte = radius[src_planet] / radius[tgt_planet]; @@ -425,7 +425,7 @@ EX void compare() { dark = dark * dark * (3-2*dark); } alpha = dark * max_alpha; - View = cspin(0, 2, (rot - lrot) * 2 * M_PI) * View; + View = cspin(0, 2, (rot - lrot) * TAU) * View; lrot = rot; anims::moved(); } diff --git a/rogueviz/platformer.cpp b/rogueviz/platformer.cpp index 2ad0c33c..a567eb99 100644 --- a/rogueviz/platformer.cpp +++ b/rogueviz/platformer.cpp @@ -85,12 +85,12 @@ hyperpoint to_hyper(ld x, ld y) { y -= 1; hyperpoint h; h[0] = -x; h[1] = y; h[2] = 1; - h = spin(-90*degree) * h; + h = spin270() * h; return perspective_to_space(h, 1, gcHyperbolic); } pair from_hyper(hyperpoint h) { - h = spin(+90*degree) * h; h[0] = -h[0]; + h = spin90() * h; h[0] = -h[0]; h[2] += 1; h /= h[2]; diff --git a/rogueviz/playing-with-impossibility.cpp b/rogueviz/playing-with-impossibility.cpp index 94c48a07..b38bebf1 100644 --- a/rogueviz/playing-with-impossibility.cpp +++ b/rogueviz/playing-with-impossibility.cpp @@ -120,7 +120,7 @@ void nil_screen(presmode mode, int id) { else t = floor(t) + 2 * (t - floor(t)); t -= floor(t/4)*4; - ld t2 = 90 * degree * t; + ld t2 = 90._deg * t; curvepoint(p2(0,0)); curvepoint(p2(5,5)); @@ -144,7 +144,7 @@ void nil_screen(presmode mode, int id) { if(id < 3) { if(id == 2) { - drawMonsterType(moEagle, nullptr, g.pos(5,5,1.5) * spin(-t * 90 * degree) * xyzscale(1.5), 0x40C040, ticks / 1000., 0); + drawMonsterType(moEagle, nullptr, g.pos(5,5,1.5) * spin(-t * 90._deg) * xyzscale(1.5), 0x40C040, ticks / 1000., 0); } color_t dark = 0xFF; @@ -305,7 +305,7 @@ void geodesic_screen(presmode mode, int id) { // flat_model_enabler fme; initquickqueue(); - dmv_grapher g(MirrorZ * cspin(1, 2, .3 * angle / (M_PI/2)) * spin(angle/2)); + dmv_grapher g(MirrorZ * cspin(1, 2, .3 * angle / 90._deg) * spin(angle/2)); ld val = 25; @@ -320,7 +320,7 @@ void geodesic_screen(presmode mode, int id) { ld rrh = radh * sqrt(1/2.); ld zmove = val - M_PI * radh * radh; - ld len = hypot(2 * M_PI * radh, zmove); + ld len = hypot(TAU * radh, zmove); ld t = inHighQual ? ticks / 1000. : (ticks - geo_zero) / 500; @@ -334,7 +334,7 @@ void geodesic_screen(presmode mode, int id) { queuecurve(g.T, col, 0, PPR::LINE); auto be_shadow = [&] (hyperpoint& h) { - // ld part = 1 - angle / (M_PI / 2); + // ld part = 1 - angle / 90._deg; // h[0] += h[2] * part / 10; h[2] = 0; }; @@ -396,8 +396,8 @@ void geodesic_screen(presmode mode, int id) { if(id >= 2) draw_path([&] (ld t) { - ld tx = min(t, 2 * M_PI * rad); - ld ta = tx / rad - 135 * degree; + ld tx = min(t, TAU * rad); + ld ta = tx / rad - 135._deg; ld x = rr + rad * cos(ta); ld y = rr + rad * sin(ta); ld z = rad * tx / 2 - ((rr * x) - (rr * y)) / 2; @@ -407,10 +407,10 @@ void geodesic_screen(presmode mode, int id) { if(id >= 3) draw_path([&] (ld t) { ld tx = min(t, len); - ld ta = tx / len * 2 * M_PI - 135 * degree; + ld ta = tx / len * TAU - 135._deg; ld x = rrh + radh * cos(ta); ld y = rrh + radh * sin(ta); - ld z = radh * radh * (tx/len*2*M_PI) / 2 - ((rrh * x) - (rrh * y)) / 2 + zmove * tx / len; + ld z = radh * radh * (tx/len*TAU) / 2 - ((rrh * x) - (rrh * y)) / 2 + zmove * tx / len; return point31(x, y, z); }, helix); @@ -447,7 +447,7 @@ void geodesic_screen(presmode mode, int id) { if(id >= 2) { dialog::addBreak(100); dialog_may_latex("\\textsf{circle}", "circle", circle >> 8); - dialog_may_latex("$"+fts(2 * M_PI * rad)+"$", fts(2 * M_PI * rad), circle >> 8); + dialog_may_latex("$"+fts(TAU * rad)+"$", fts(TAU * rad), circle >> 8); } else dialog::addBreak(300); @@ -553,7 +553,7 @@ void impossible_ring_slide(tour::presmode mode) { for(int id=0; id<2; id++) { shiftmatrix T = ggmatrix(currentmap->gamestart()); println(hlog, "angle = ", angle); - if(id == 1) T = T * spin(180*degree) * xpush(1.5) * cspin(0, 2, angle) * xpush(-1.5); + if(id == 1) T = T * spin180() * xpush(1.5) * cspin(0, 2, angle) * xpush(-1.5); for(ld z: {+.5, -.5}) { for(ld d=0; d<=180; d++) @@ -599,7 +599,7 @@ void enable_earth() { texture::config.color_alpha = 255; mapeditor::drawplayer = false; fullcenter(); - View = spin(4 * M_PI / 5 + M_PI / 2) * View; + View = spin(234._deg) * View; } slide dmv_slides[] = { @@ -647,8 +647,8 @@ slide dmv_slides[] = { shiftmatrix T = ggmatrix(currentmap->gamestart()); vid.linewidth *= 4; shiftpoint h1 = T * xspinpush0(0, 2); - shiftpoint h2 = T * xspinpush0(120*degree, 2); - shiftpoint h3 = T * xspinpush0(240*degree, 2); + shiftpoint h2 = T * xspinpush0(120._deg, 2); + shiftpoint h3 = T * xspinpush0(240._deg, 2); queueline(h1, h2, 0xFF0000FF, 4); queueline(h2, h3, 0xFF0000FF, 4); queueline(h3, h1, 0xFF0000FF, 4); @@ -669,21 +669,21 @@ slide dmv_slides[] = { enable_earth(); View = Id; - View = spin(3 * M_PI / 5) * View; - View = spin(90*degree) * View; - View = cspin(2, 0, 45 * degree) * View; - View = cspin(1, 2, 30 * degree) * View; + View = spin(108._deg) * View; + View = spin(90._deg) * View; + View = cspin(2, 0, 45._deg) * View; + View = cspin(1, 2, 30._deg) * View; playermoved = false; tour::slide_backup(vid.axes, 0); tour::slide_backup(vid.drawmousecircle, false); tour::slide_backup(draw_centerover, false); } add_temporary_hook(mode, hooks_frame, 200, [] { - shiftmatrix T = ggmatrix(currentmap->gamestart()) * spin(-3 * M_PI / 5); + shiftmatrix T = ggmatrix(currentmap->gamestart()) * spin(-108._deg); vid.linewidth *= 4; shiftpoint h1 = T * C0; - shiftpoint h2 = T * xpush0(M_PI/2); - shiftpoint h3 = T * ypush0(M_PI/2); + shiftpoint h2 = T * xpush0(90._deg); + shiftpoint h3 = T * ypush0(90._deg); queueline(h1, h2, 0xFF0000FF, 3); queueline(h2, h3, 0xFF0000FF, 3); queueline(h3, h1, 0xFF0000FF, 3); @@ -734,8 +734,8 @@ slide dmv_slides[] = { shiftmatrix T = ggmatrix(currentmap->gamestart()); vid.linewidth *= 16; shiftpoint h1 = T * xspinpush0(0, 2); - shiftpoint h2 = T * xspinpush0(120*degree, 2); - shiftpoint h3 = T * xspinpush0(240*degree, 2); + shiftpoint h2 = T * xspinpush0(120._deg, 2); + shiftpoint h3 = T * xspinpush0(240._deg, 2); queueline(h1, h2, 0xFF0000FF, 4); queueline(h2, h3, 0xFF0000FF, 4); queueline(h3, h1, 0xFF0000FF, 4); @@ -1270,7 +1270,7 @@ slide dmv_slides[] = { rogueviz::balls::initialize(1); rogueviz::balls::balls.resize(3); pmodel = mdEquidistant; - View = cspin(1, 2, M_PI/2); + View = cspin90(1, 2); } non_game_slide_scroll(mode); } diff --git a/rogueviz/presentation.cpp b/rogueviz/presentation.cpp index 8da015a4..3a1f1248 100644 --- a/rogueviz/presentation.cpp +++ b/rogueviz/presentation.cpp @@ -46,8 +46,8 @@ void grapher::arrow(hyperpoint h1, hyperpoint h2, ld sca, color_t col) { ld siz = hypot_d(2, h); h *= sca / siz; curvepoint(h2); - curvepoint(h2 - spin(15*degree) * h); - curvepoint(h2 - spin(-15*degree) * h); + curvepoint(h2 - spin(15._deg) * h); + curvepoint(h2 - spin(-15._deg) * h); curvepoint(h2); queuecurve(T, col, col, PPR::LINE); } @@ -429,7 +429,7 @@ void use_angledir(presmode mode, bool reset) { angle = 0, dir = -1; add_temporary_hook(mode, shmup::hooks_turn, 200, [] (int i) { angle += dir * i / 500.; - if(angle > M_PI/2) angle = M_PI/2; + if(angle > 90._deg) angle = 90._deg; if(angle < 0) angle = 0; return false; }); diff --git a/rogueviz/qtm.cpp b/rogueviz/qtm.cpp index a3b6d5f0..670c2b2c 100644 --- a/rogueviz/qtm.cpp +++ b/rogueviz/qtm.cpp @@ -25,7 +25,7 @@ int qmode; color_t rainbow_color_at(hyperpoint h) { ld sat = 1 - 1 / h[2]; - ld hue = atan2(h[0], h[1]) / (2 * M_PI); + ld hue = atan2(h[0], h[1]) / TAU; return rainbow_color(sat, hue); } diff --git a/rogueviz/random-walk.cpp b/rogueviz/random-walk.cpp index 7636eb95..4b57635d 100644 --- a/rogueviz/random-walk.cpp +++ b/rogueviz/random-walk.cpp @@ -71,7 +71,7 @@ bool advance_walkers(int delta) { auto& w = walkers[i]; hyperpoint h = tC0(w.T); if(WDIM == 2) { - w.T = w.T * xspinpush(randd() * 2 * M_PI, step_size); + w.T = w.T * xspinpush(randd() * TAU, step_size); } else { hyperpoint dir = random_spin() * xtangent(step_size); diff --git a/rogueviz/reverb.cpp b/rogueviz/reverb.cpp index 4b5e1eba..b5d1364c 100644 --- a/rogueviz/reverb.cpp +++ b/rogueviz/reverb.cpp @@ -204,7 +204,7 @@ bool draw_bird(cell *c, const transmatrix& V) { id++; if(id == isize(orig)) id = 0; } id = tot * WINGS / maxvol / 2; - queuepoly(rgpushxto0(tC0(V)) * cspin(0, 2, M_PI/2) * cspin(1, 2, 90 * degree) * cspin(0, 2, 45 * degree), + queuepoly(rgpushxto0(tC0(V)) * cspin90(0, 2) * cspin90(1, 2) * cspin(0, 2, 45._deg), GDIM == 3 ? cgi.shAnimatedTinyEagle[id] : cgi.shTinyBird, 0xFFFFFFFF ); } @@ -312,9 +312,9 @@ auto hchook = addHook(hooks_drawcell, 100, draw_bird) hyperpoint h = all[int(id)] * (1-id+int(id)) + all[int(id+1)] * (id-int(id)); h = normalize(h); centerover = currentmap->gamestart(); - View = /* cspin(2, 0, M_PI/2) * rspintox(gpushxto0(h) * C0) * */ gpushxto0(h); + View = /* cspin90(2, 0) * rspintox(gpushxto0(h) * C0) * */ gpushxto0(h); View = spintox(View * C0) * View; - View = cspin(2, 0, M_PI/2) * View; + View = cspin90(2, 0) * View; shift_view(point3(0, 0, -1e-2)); diff --git a/rogueviz/sample.cpp b/rogueviz/sample.cpp index 02b544c1..3dca503d 100644 --- a/rogueviz/sample.cpp +++ b/rogueviz/sample.cpp @@ -16,8 +16,8 @@ bool draw_simple_scene() { shiftmatrix Where = ggmatrix(currentmap->gamestart()); curvepoint(xpush0(0.2)); - curvepoint(spin(120*degree) * xpush0(0.2)); - curvepoint(spin(240*degree) * xpush0(0.2)); + curvepoint(spin(120._deg) * xpush0(0.2)); + curvepoint(spin(240._deg) * xpush0(0.2)); curvepoint(xpush0(0.2)); queuecurve(Where, 0xFF0000FF, 0x00FF00FF, PPR::LINE); diff --git a/rogueviz/simple-impossible.cpp b/rogueviz/simple-impossible.cpp index 57c908de..95640e52 100644 --- a/rogueviz/simple-impossible.cpp +++ b/rogueviz/simple-impossible.cpp @@ -180,7 +180,7 @@ void draw_ro() { vector path; void build(bool in_pair) { - to_iso = cspin(1, 2, atan(1/sqrt(2))) * cspin(0, 2, M_PI/4); + to_iso = cspin(1, 2, atan(1/sqrt(2))) * cspin(0, 2, 45._deg); from_iso = inverse(to_iso); last_co = euc::coord(0, 0, 3); @@ -242,7 +242,7 @@ void build(bool in_pair) { } void build_net() { - to_iso = cspin(1, 2, atan(1/sqrt(2))) * cspin(0, 2, M_PI/4); + to_iso = cspin(1, 2, atan(1/sqrt(2))) * cspin(0, 2, 45._deg); from_iso = inverse(to_iso); last_co = euc::coord(0, 0, 0); @@ -315,22 +315,22 @@ void build_stair() { hs[3] = point31(+xx, -xx, -hei); } else if(dix == 3 || (dix == 2 && step == 0) || (dix == 1 && step > 0)) { - transmatrix T = spin(90*degree*diy); + transmatrix T = spin(90._deg*diy); hs[0] = T * point31(+xx, -xx, -hei); hs[1] = T * point31(+xx, +xx, -hei); hs[2] = T * point31(+xx, +xx, +hei); hs[3] = T * point31(+xx, -xx, +hei); } else if(dix == 0) { - transmatrix T = spin(90*degree*diy); + transmatrix T = spin(90._deg*diy); hs[0] = T * point31(+xx, -xx, -hei); hs[1] = T * point31(+xx, +xx, -hei); hs[2] = to_rot(eupush(C0 + shift) * to_heis(T * point31(-xx, +xx, -hei))); hs[3] = to_rot(eupush(C0 + shift) * to_heis(T * point31(-xx, -xx, -hei))); } else { - transmatrix T = spin(90*degree*diy); - hyperpoint lshift = step ? shift : spin(-90*degree) * shift; + transmatrix T = spin(90._deg*diy); + hyperpoint lshift = step ? shift : spin270() * shift; hs[0] = to_rot(eupush(C0 - lshift) * to_heis(T * point31(-xx, +xx, hei))); hs[1] = to_rot(eupush(C0 - lshift) * to_heis(T * point31(-xx, -xx, hei))); hs[2] = T * point31(+xx, -xx, hei); @@ -343,7 +343,7 @@ void build_stair() { at = eupush(at) * (C0 + shift); } - shift = spin(90*degree) * shift; + shift = spin90() * shift; } println(hlog, "path = ", path); diff --git a/rogueviz/smoothcam.cpp b/rogueviz/smoothcam.cpp index 05c665ad..ad42df72 100644 --- a/rogueviz/smoothcam.cpp +++ b/rogueviz/smoothcam.cpp @@ -281,22 +281,22 @@ void snap_to_center() { dialog::addItem("mouse up", 'w'); dialog::add_action([] { - View = spin(90*degree) * spintox(unshift(mapeditor::mouse_snap())) * View; + View = spin90() * spintox(unshift(mapeditor::mouse_snap())) * View; }); dialog::addItem("mouse down", 's'); dialog::add_action([] { - View = spin(-90*degree) * spintox(unshift(mapeditor::mouse_snap())) * View; + View = spin270() * spintox(unshift(mapeditor::mouse_snap())) * View; }); dialog::addItem("mouse left", 'a'); dialog::add_action([] { - View = spin(180*degree) * spintox(unshift(mapeditor::mouse_snap())) * View; + View = spin180() * spintox(unshift(mapeditor::mouse_snap())) * View; }); dialog::addItem("mouse left", 'd'); dialog::add_action([] { - View = spin(0*degree) * spintox(unshift(mapeditor::mouse_snap())) * View; + View = Id * spintox(unshift(mapeditor::mouse_snap())) * View; }); dialog::addBack(); diff --git a/rogueviz/som/embeddings.cpp b/rogueviz/som/embeddings.cpp index cc266d0c..38fd8d6e 100644 --- a/rogueviz/som/embeddings.cpp +++ b/rogueviz/som/embeddings.cpp @@ -93,7 +93,7 @@ ld hrandd() { ld gaussian_random() { ld u1 = hrandd(); ld u2 = hrandd(); - return sqrt(-2*log(u1)) * cos(2*M_PI*u2); + return sqrt(-2*log(u1)) * cos(TAU*u2); } void apply_delta(cellwalker cw, kohvec& v) { @@ -226,9 +226,9 @@ void get_coordinates(kohvec& v, cell *c, cell *c0) { alloc(v); int s = T0[0][0]; for(int i=0; i<3; i++) { - hyperpoint h1 = spin(120*degree*i) * h; + hyperpoint h1 = spin(120._deg*i) * h; ld x = h1[1]; - ld alpha = 2 * M_PI * x / s / (sqrt(3) / 2); + ld alpha = TAU * x / s / (sqrt(3) / 2); // println(hlog, kz(x), " -> ", kz(alpha)); v[2*i] = cos(alpha); v[2*i+1] = sin(alpha); @@ -250,7 +250,7 @@ void get_coordinates(kohvec& v, cell *c, cell *c0) { auto& T0 = eu_input.user_axes; for(int i=0; i<3; i++) { int s = T0[i][i]; - ld alpha = 2 * M_PI * h[i] / s; + ld alpha = TAU * h[i] / s; v[2*i] = cos(alpha) * s; v[2*i+1] = sin(alpha) * s; } diff --git a/rogueviz/som/kohonen.cpp b/rogueviz/som/kohonen.cpp index 2f33710c..e0f48d6b 100644 --- a/rogueviz/som/kohonen.cpp +++ b/rogueviz/som/kohonen.cpp @@ -358,7 +358,7 @@ void distribute_neurons() { if(!triangulate(data[s].val, w, find, vdata[id].m->at)) vdata[id].m->at = - spin(2*M_PI*w.csample / w.drawn_samples) * xpush(rad * (w.drawn_samples-1) / w.drawn_samples); + spin(TAU*w.csample / w.drawn_samples) * xpush(rad * (w.drawn_samples-1) / w.drawn_samples); w.csample++; for(auto& e: vdata[id].edges) e.second->orig = nullptr; } diff --git a/rogueviz/som/tests.cpp b/rogueviz/som/tests.cpp index eadf9f7c..e6c834bf 100644 --- a/rogueviz/som/tests.cpp +++ b/rogueviz/som/tests.cpp @@ -735,7 +735,7 @@ void shot_settings() { brm_limit = GDIM == 2 ? 1000 : 0; if(GDIM == 3) - View = cspin(0, 2, 30 * degree) * cspin(1, 2, 30*degree) * View; + View = cspin(0, 2, 30 * degree) * cspin(1, 2, 30._deg) * View; shift_view(ctangent(2, -0.5)); diff --git a/rogueviz/spiral.cpp b/rogueviz/spiral.cpp index d5f11e88..0b9ff650 100644 --- a/rogueviz/spiral.cpp +++ b/rogueviz/spiral.cpp @@ -13,7 +13,7 @@ namespace spiral { ld mul; transmatrix at(double d) { - return spin(log(d) * 2 * M_PI / log(mul)) * xpush(log(d)); + return spin(log(d) * TAU / log(mul)) * xpush(log(d)); } void place(int N, ld _mul) { diff --git a/rogueviz/staircase.cpp b/rogueviz/staircase.cpp index 96b15a3f..16ec930f 100644 --- a/rogueviz/staircase.cpp +++ b/rogueviz/staircase.cpp @@ -19,7 +19,7 @@ basic_textureinfo tinf; hyperpoint spcoord(hyperpoint h) { ld phi = h[0], y = h[1], z = h[2], r = global_r; - ld aphi = (r+phi + floor(progress))*M_PI/6; + ld aphi = (r+phi + floor(progress))*30._deg; return zpush(acurvature*(y + r - frac(progress))/szoom) * xspinpush0(aphi, acurvature * z); } @@ -106,7 +106,7 @@ void make_texture() { pix(2,x,y) = 0xFF400000 + 0x10000 * (y * 63 / fw); pix(8,x,y) = 0xFF101010; pix(10,x,y) = 0xFF000000 + gradient(0, 0xFFD500, 0, x*(fw-x), fw*fw/4); - pix(5,x,y) = 0xFF000000 + gradient(0, 0x804000, -1, sin(2*M_PI*8*y/fw), 1); + pix(5,x,y) = 0xFF000000 + gradient(0, 0x804000, -1, sin(TAU*8*y/fw), 1); pix(7,x,y) = 0xFF000000 + gradient(0, 0x808080, 0, x*ll(fw-x)*y*(fw-y), ll(fw/2)*(fw/2)*(fw-fw/2)*(fw-fw/2)); } diff --git a/rogueviz/sunflower.cpp b/rogueviz/sunflower.cpp index 80ca7f06..64c31f7f 100644 --- a/rogueviz/sunflower.cpp +++ b/rogueviz/sunflower.cpp @@ -74,8 +74,8 @@ bool sunflower_cell(cell *c, shiftmatrix V) { if(sphere) { if(infer == 'r') - range = qty * density * M_PI/2; - else qd = range * 2/M_PI; + range = qty * density * 90._deg; + else qd = range / 90._deg; } else if(euclid) { if(infer == 'r') @@ -108,7 +108,7 @@ bool sunflower_cell(cell *c, shiftmatrix V) { ld best_error = 1; vector sgns; for(int i=1; i .5; if(sgn) v = 1-v; @@ -263,7 +263,7 @@ void show() { dialog::addSelItem("radius", fts(range), 'q'); dialog::add_action([] { if(infer == 'r') infer = 'd'; - dialog::editNumber(range, 0, 10, .1, 2*M_PI, "range", "range"); + dialog::editNumber(range, 0, 10, .1, TAU, "range", "range"); dialog::scaleLog(); }); diff --git a/rug.cpp b/rug.cpp index c7af552f..a2bc2cef 100644 --- a/rug.cpp +++ b/rug.cpp @@ -191,16 +191,14 @@ EX rugpoint *addRugpoint(shiftpoint h, double dist) { ld d = h1[0] * h[1] - h1[1] * h[0]; ld a = h[0] * h1[0] + h[1] * h1[1]; - // m->flat = modelscale * hpxyz(d * 2 * M_PI, sin(a * 2 * M_PI), cos(a * 2 * M_PI)); - USING_NATIVE_GEOMETRY; - hyperpoint hpoint = ypush(modelscale) * xpush0(modelscale * d * 2 * M_PI); + hyperpoint hpoint = ypush(modelscale) * xpush0(modelscale * d * TAU); ld hpdist = hdist0(hpoint); ld z = hypot_d(2, hpoint); if(z==0) z = 1; hpoint = hpoint * hpdist / z; - m->native = point31(hpoint[0], hpoint[1] * sin(a*2*M_PI), hpoint[1]*cos(a*2*M_PI)); + m->native = point31(hpoint[0], hpoint[1] * sin(a*TAU), hpoint[1]*cos(a*TAU)); } else if(sphere) { m->valid = good_shape = true; @@ -216,7 +214,7 @@ EX rugpoint *addRugpoint(shiftpoint h, double dist) { else if(sphere) { if(modelscale >= 1) // do as good as we can... - scale = M_PI / 2 - 1e-3, good_shape = false, m->valid = false; + scale = 90._deg - 1e-3, good_shape = false, m->valid = false; else scale = asin(modelscale); } else @@ -374,15 +372,15 @@ struct clifford_torus { } clifford_torus(); ld get_modelscale() { - return hypot_d(2, xh) * xfactor * 2 * M_PI; + return hypot_d(2, xh) * xfactor * TAU; } ld compute_mx(); }; #endif struct hyperpoint clifford_torus::torus_to_s4(hyperpoint t) { - double alpha = -t[0] * 2 * M_PI; - double beta = t[1] * 2 * M_PI; + double alpha = -t[0] * TAU; + double beta = t[1] * TAU; ld ax = alpha + 1.124651, bx = beta + 1.214893; return hyperpoint( @@ -1085,7 +1083,7 @@ EX void prepareTexture() { shiftmatrix V = rgpushxto0(finger_center->h); queuestr(V, 0.5, "X", 0xFFFFFFFF, 2); for(int i=0; i<72; i++) - queueline(V * xspinpush0(i*M_PI/32, finger_range), V * xspinpush0((i+1)*M_PI/32, finger_range), 0xFFFFFFFF, vid.linequality); + queueline(V * xspinpush0(i*A_PI/32, finger_range), V * xspinpush0((i+1)*A_PI/32, finger_range), 0xFFFFFFFF, vid.linequality); } drawqueue(); calcparam(); @@ -1286,7 +1284,7 @@ EX bool handlekeys(int sym, int uni) { crystal::switch_z_coordinate(); else #endif - rotate_view(cspin(0, 2, M_PI)); + rotate_view(cspin180(0, 2)); return true; } else if(NUMBERKEY == '4') { @@ -1295,7 +1293,7 @@ EX bool handlekeys(int sym, int uni) { crystal::flip_z(); else #endif - rotate_view(cspin(0, 2, M_PI/2)); + rotate_view(cspin90(0, 2)); return true; } #if CAP_CRYSTAL @@ -1573,7 +1571,7 @@ EX void show() { if(rug::rugged) dialog::addSelItem(XLAT("model iterations"), its(queueiter), 0); dialog::addItem(XLAT("stereo vision config"), 'f'); - // dialog::addSelItem(XLAT("protractor"), fts(protractor * 180 / M_PI) + "°", 'f'); + // dialog::addSelItem(XLAT("protractor"), fts(protractor / degree) + "°", 'f'); if(!good_shape) { dialog::addSelItem(XLAT("maximum error"), fts(err_zero), 'e'); if(rug::rugged) diff --git a/screenshot.cpp b/screenshot.cpp index 02320100..ce4dfc9c 100644 --- a/screenshot.cpp +++ b/screenshot.cpp @@ -1125,7 +1125,7 @@ EX ld shift_angle, movement_angle, movement_angle_2; EX ld normal_angle = 90; EX ld period = 10000; EX int noframes = 30; -EX ld cycle_length = 2 * M_PI; +EX ld cycle_length = TAU; EX ld parabolic_length = 1; EX ld skiprope_rotation; @@ -1282,7 +1282,7 @@ EX void apply() { rotate_view(cspin(1, 2, normal_angle * degree)); rotate_view(spin(-movement_angle_2 * degree)); } - rotate_view(spin(2 * M_PI * t / period)); + rotate_view(spin(TAU * t / period)); if(GDIM == 3) { rotate_view(spin(movement_angle_2 * degree)); rotate_view(cspin(2, 1, normal_angle * degree)); @@ -1297,7 +1297,7 @@ EX void apply() { cspin(0, GDIM-1, movement_angle * degree) * spin(shift_angle * degree) * xtangent(cycle_length * t / period) ); moved(); - rotate_view(cspin(0, GDIM-1, 2 * M_PI * t / period)); + rotate_view(cspin(0, GDIM-1, TAU * t / period)); if(clearup) { centerover->wall = waNone; } @@ -1317,7 +1317,7 @@ EX void apply() { #endif case maCircle: { centerover = rotation_center; - ld alpha = circle_spins * 2 * M_PI * ticks / period; + ld alpha = circle_spins * TAU * ticks / period; View = spin(-cos_auto(circle_radius)*alpha) * xpush(circle_radius) * spin(alpha) * rotation_center_View; moved(); break; @@ -1341,17 +1341,17 @@ EX void apply() { if(rug::rugged) { if(rug_rotation1) { rug::using_rugview rv; - rotate_view(cspin(1, 2, -rug_angle * degree) * cspin(0, 2, rug_rotation1 * 2 * M_PI * t / period) * cspin(1, 2, rug_angle * degree)); + rotate_view(cspin(1, 2, -rug_angle * degree) * cspin(0, 2, rug_rotation1 * TAU * t / period) * cspin(1, 2, rug_angle * degree)); } if(rug_rotation2) { rug::using_rugview rv; - View = View * cspin(0, 1, rug_rotation2 * 2 * M_PI * t / period); + View = View * cspin(0, 1, rug_rotation2 * TAU * t / period); } if(rug_forward) animate_rug_movement(rug_forward * t / period); } #endif - pconf.skiprope += skiprope_rotation * t * 2 * M_PI / period; + pconf.skiprope += skiprope_rotation * t * TAU / period; if(ballangle_rotation) { if(models::has_orientation(vpconf.model)) @@ -1485,12 +1485,12 @@ void display_animation() { if(ma == maCircle && (circle_display_color & 0xFF)) { for(int s=0; s<10; s++) { if(s == 0) curvepoint(xpush0(circle_radius - .1)); - for(int z=0; z<100; z++) curvepoint(xspinpush0((z+s*100) * 2 * M_PI / 1000., circle_radius)); + for(int z=0; z<100; z++) curvepoint(xspinpush0((z+s*100) * 2 * A_PI / 1000., circle_radius)); queuecurve(ggmatrix(rotation_center), circle_display_color, 0, PPR::LINE); } if(sphere) for(int s=0; s<10; s++) { if(s == 0) curvepoint(xpush0(circle_radius - .1)); - for(int z=0; z<100; z++) curvepoint(xspinpush0((z+s*100) * 2 * M_PI / 1000., circle_radius)); + for(int z=0; z<100; z++) curvepoint(xspinpush0((z+s*100) * 2 * A_PI / 1000., circle_radius)); queuecurve(ggmatrix(rotation_center) * centralsym, circle_display_color, 0, PPR::LINE); } } @@ -1534,7 +1534,7 @@ EX void show() { cmode = sm::SIDE; needs_highqual = false; animation_lcm = 1; gamescreen(); - animation_period = 2 * M_PI * animation_lcm / animation_factor; + animation_period = TAU * animation_lcm / animation_factor; dialog::init(XLAT("animations"), iinf[itPalace].color, 150, 100); dialog::addSelItem(XLAT("period"), fts(period)+ " ms", 'p'); dialog::add_action([] () { dialog::editNumber(period, 0, 10000, 1000, 200, XLAT("period"), @@ -1547,7 +1547,7 @@ EX void show() { dialog::editNumber(animation_period, 0, 10000, 1000, 1000, XLAT("game animation period"), XLAT("Least common multiple of the animation periods of all the game objects on screen, such as rotating items.") ); - dialog::reaction = [] () { animation_factor = 2 * M_PI * animation_lcm / animation_period; }; + dialog::reaction = [] () { animation_factor = TAU * animation_lcm / animation_period; }; dialog::extra_options = [] () { dialog::addItem("default", 'D'); dialog::add_action([] () { @@ -1614,10 +1614,10 @@ EX void show() { else if(ma == maTranslation) { dialog::addSelItem(XLAT("cycle length"), fts(cycle_length), 'c'); dialog::add_action([] () { - dialog::editNumber(cycle_length, 0, 10, 0.1, 2*M_PI, "shift", ""); + dialog::editNumber(cycle_length, 0, 10, 0.1, TAU, "shift", ""); dialog::extra_options = [] () { - dialog::addSelItem(XLAT("full circle"), fts(2 * M_PI), 'A'); - dialog::add_action([] () { cycle_length = 2 * M_PI; }); + dialog::addSelItem(XLAT("full circle"), fts(TAU), 'A'); + dialog::add_action([] () { cycle_length = TAU; }); dialog::addSelItem(XLAT("Zebra period"), fts(2.898149445355172), 'B'); dialog::add_action([] () { cycle_length = 2.898149445355172; }); dialog::addSelItem(XLAT("Bolza period"), fts(2 * 1.528571), 'C'); @@ -1690,7 +1690,7 @@ EX void show() { dialog::extra_options = [] () { if(among(rug::gwhere, gSphere, gElliptic)) { dialog::addItem(XLAT("synchronize"), 'S'); - dialog::add_action([] () { rug_forward = 2 * M_PI; popScreen(); }); + dialog::add_action([] () { rug_forward = TAU; popScreen(); }); } rug_angle_options(); }; @@ -1967,7 +1967,7 @@ startanim rug { "Hypersian Rug", [] { startanim spin_around { "spinning around", no_init, [] { dynamicval da(pconf.alpha, 999); dynamicval ds(pconf.scale, 500); - ld alpha = 2 * M_PI * ticks / 10000.; + ld alpha = TAU * ticks / 10000.; ld circle_radius = acosh(2.); dynamicval dv(View, spin(-cos_auto(circle_radius)*alpha) * xpush(circle_radius) * spin(alpha) * View); gamescreen(); @@ -1996,7 +1996,7 @@ startanim row_of_ghosts { "row of ghosts", no_init, [] { for(int x=-25; x<=25; x++) for(int y=-25; y<=25; y++) { ld ay = (y + mod)/5.; - draw_ghost(xpush(x/5.) * spin(M_PI/2) * xpush(ay), int(y-t)); + draw_ghost(xpush(x/5.) * spin90() * xpush(ay), int(y-t)); } }); dynamicval rd(mapeditor::drawplayer, false); @@ -2011,15 +2011,15 @@ startanim army_of_ghosts { "army of ghosts", no_init, [] { ld mod = (tt-t*400)/400.; for(int x=-12; x<=12; x++) { ld ax = x/4.; - transmatrix T = spin(-M_PI/2) * xpush(ax) * spin(M_PI/2); + transmatrix T = spin270() * xpush(ax) * spin90(); for(int y=0;; y++) { ld ay = (mod - y)/4.; - transmatrix U = spin(M_PI/2) * xpush(ay / cosh(ax)) * T; + transmatrix U = spin90() * xpush(ay / cosh(ax)) * T; if(!in_smart_range(shiftless(U))) break; draw_ghost(U, (-y - t)); if(y) { ay = (mod + y)/4.; - transmatrix U = spin(M_PI/2) * xpush(ay / cosh(ax)) * T; + transmatrix U = spin90() * xpush(ay / cosh(ax)) * T; draw_ghost(U, (y - t)); } } @@ -2032,7 +2032,7 @@ startanim ghost_spiral { "ghost spiral", no_init, [] { dynamicval r(add_to_frame, [] { ld t = (ticks - ticks_start - 2000) / 150000.; for(ld i=3; i<=40; i++) { - draw_ghost(spin(t * i * 2 * M_PI) * xpush(asinh(15. / i)) * spin(M_PI/2), 1); + draw_ghost(spin(t * i * TAU) * xpush(asinh(15. / i)) * spin90(), 1); } }); gamescreen(); @@ -2043,12 +2043,12 @@ startanim fib_ghosts { "Fibonacci ghosts", no_init, [] { dynamicval r(add_to_frame, [] { ld phase = (ticks - ticks_start - 2000) / 1000.; for(int i=0; i<=500; i++) { - ld step = M_PI * (3 - sqrt(5)); + ld step = A_PI * (3 - sqrt(5)); ld density = 0.01; ld area = 1 + (i+.5) * density; ld r = acosh(area); ld length = sinh(r); - transmatrix T = spin(i * step + phase / length) * xpush(r) * spin(M_PI/2); + transmatrix T = spin(i * step + phase / length) * xpush(r) * spin90(); draw_ghost(T, i); } }); diff --git a/shaders.cpp b/shaders.cpp index a8f753a7..22456701 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -798,7 +798,7 @@ void display_data::set_projection(int ed, ld shift) { glhr::projection_multiply(model_orientation_gl()); if(selected->shader_flags & SF_BAND) - glhr::projection_multiply(glhr::scale(2 / M_PI, 2 / M_PI, GDIM == 3 ? 2/M_PI : 1)); + glhr::projection_multiply(glhr::scale(1 / 90._deg, 1 / 90._deg, GDIM == 3 ? 1/90._deg : 1)); if(selected->shader_flags & SF_BAND) { glhr::projection_multiply(glhr::translate(shift, 0, 0)); diff --git a/shmup.cpp b/shmup.cpp index 2f53a72d..f2f07527 100644 --- a/shmup.cpp +++ b/shmup.cpp @@ -440,7 +440,7 @@ void shootBullet(monster *m) { for(int i=1; i<8; i++) if(markOrb(orbdir[i])) { monster* bullet = new monster; bullet->base = m->base; - bullet->at = m->at * cspin(0, WDIM-1, M_PI/4*i); + bullet->at = m->at * cspin(0, WDIM-1, TAU * i/8); if(prod) bullet->ori = m->ori; if(WDIM == 3) bullet->at = bullet->at * cpush(2, 0.15 * SCALE); bullet->type = moBullet; @@ -448,7 +448,7 @@ void shootBullet(monster *m) { bullet->pid = m->pid; bullet->hitpoints = 0; bullet->fragoff = ticks + bullet_time; - bullet->inertia = cspin(0, WDIM-1, -M_PI/4 * i) * m->inertia; + bullet->inertia = cspin(0, WDIM-1, -TAU * i/8) * m->inertia; bullet->inertia[frontdir()] += bullet_velocity(m->type) * SCALE; additional.push_back(bullet); } @@ -635,10 +635,10 @@ shiftpoint hornpos(int id) { #define IGO 9 double igospan[IGO+1] = { 0, - M_PI/6, -M_PI/6, - M_PI/4, -M_PI/4, - M_PI/3, -M_PI/3, - M_PI/2.1, -M_PI/2.1, + A_PI/6, -A_PI/6, + A_PI/4, -A_PI/4, + A_PI/3, -A_PI/3, + A_PI/2.1, -A_PI/2.1, 0 }; @@ -1527,7 +1527,7 @@ void destroyMimics() { EX void teleported() { monster *m = pc[cpid]; m->base = cwt.at; - m->at = rgpushxto0(inverse_shift(gmatrix[cwt.at], mouseh)) * spin(rand() % 1000 * M_PI / 2000); + m->at = rgpushxto0(inverse_shift(gmatrix[cwt.at], mouseh)) * random_spin(); m->findpat(); destroyMimics(); } @@ -2161,9 +2161,9 @@ void moveMonster(monster *m, int delta) { if(m->type == moHedge) { hyperpoint h = inverse_shift(m->pat, tC0(goal)); if(h[1] < 0) - nat = nat * spin(M_PI * delta / 3000 / speedfactor()); + nat = nat * spin(A_PI * delta / 3000 / speedfactor()); else - nat = nat * spin(M_PI * -delta / 3000 / speedfactor()); + nat = nat * spin(A_PI * -delta / 3000 / speedfactor()); m->rebasePat(nat, m->base); // at most 45 degrees if(h[0] < fabsl(h[1])) return; @@ -2832,7 +2832,7 @@ EX void recall() { if(players == 1) pc[i]->at = Id; else - pc[i]->at = spin(2*M_PI*i/players) * xpush(firstland == laMotion ? .5 : .3) * Id; + pc[i]->at = spin(TAU*i/players) * xpush(firstland == laMotion ? .5 : .3) * Id; /* ggmatrix(cwt.at); display(gmatrix[cwt.at]); pc[i]->findpat(); */ @@ -2851,7 +2851,7 @@ EX void init() { if(players == 1) pc[i]->at = Id; else - pc[i]->at = spin(2*M_PI*i/players) * xpush(firstland == laMotion ? .5 : .3) * Id; + pc[i]->at = spin(TAU*i/players) * xpush(firstland == laMotion ? .5 : .3) * Id; pc[i]->pat = shiftless(pc[i]->at); pc[i]->base = cwt.at; pc[i]->vel = 0; @@ -3013,7 +3013,7 @@ bool celldrawer::draw_shmup_monster() { if(m->inBoat) { view = m->pat; if(WDIM == 2) Vboat = view; - if(WDIM == 3) Vboat = view * spin(-M_PI/2); + if(WDIM == 3) Vboat = view * spin270(); bool magic = m->type == moPlayer && items[itOrbWater]; color_t outcolor = magic ? watercolor(0) : 0xC06000FF; @@ -3056,7 +3056,7 @@ bool celldrawer::draw_shmup_monster() { view = view * spin(-atan2(h[1], h[0])); } else { - view = view * spin(-M_PI/2) * cspin(0, 2, -M_PI/2); + view = view * spin270() * cspin90(2, 0); } } if(m->inBoat) m->footphase = 0; @@ -3167,12 +3167,7 @@ bool celldrawer::draw_shmup_monster() { if(hasHitpoints(m->type)) c->hitpoints = m->hitpoints; if(m->type == moTortoise) tortoise::emap[c] = getBits(m->torigin) & ((1<type == moMimic && GDIM == 3) - drawMonsterType(m->type, c, view * spin(-M_PI/2), col, m->footphase); */ - /* else if(GDIM == 3) - drawMonsterType(m->type, c, view * cspin(0, 2, M_PI/2), col, m->footphase); */ - /* else */ - drawMonsterType(m->type, c, view, col, m->footphase, col); + drawMonsterType(m->type, c, view, col, m->footphase, col); if(m->type == moTortoise) tortoise::emap.erase(c); break; } diff --git a/surface.cpp b/surface.cpp index a29a43a5..3a119700 100644 --- a/surface.cpp +++ b/surface.cpp @@ -72,7 +72,7 @@ hyperpoint coord(hyperpoint h) { } case dsDini: { - ld t = h[0]; // atan(h[0])/2 + M_PI * 3/ 4; + ld t = h[0]; ld v = h[1]; ld a = sqrt(1-dini_b*dini_b); @@ -166,11 +166,11 @@ ld compute_curvature(hyperpoint at) { hyperpoint shape_origin() { switch(sh) { case dsDini: - return point31(M_PI * .82, 0, 0); + return point31(A_PI * .82, 0, 0); case dsTractricoid: return point31(1, 0, 0); case dsKuen: - return point31(M_PI * .500001, M_PI * 1, 0); + return point31(90._deg * 1.000001, M_PI, 0); case dsHyperlike: return point31(0,0,0); default: @@ -206,13 +206,13 @@ int surface_branch(hyperpoint p) { bool inbound(ld& x, ld& y) { switch(sh) { case dsDini: - return flag_clamp(x, M_PI/2, M_PI); + return flag_clamp(x, 90._deg, M_PI); case dsTractricoid: return flag_clamp_min(x, 0) & flag_clamp_sym(y, M_PI); case dsKuen: - return flag_clamp(x, 0, M_PI) & flag_clamp(y, 0, 2*M_PI); + return flag_clamp(x, 0, M_PI) & flag_clamp(y, 0, TAU); case dsHyperlike: return flag_clamp_sym(x, M_PI) & flag_clamp_sym(y, hyperlike_bound()); @@ -351,7 +351,7 @@ ld kuen_hypot(ld v, ld u) { } int kuen_branch(ld v, ld u) { - if(v > M_PI/2) + if(v > 90._deg) return kuen_cross(v, u)[2] > 0 ? 1 : 2; else return kuen_cross(v, u)[2] < 0 ? 1 : 2; @@ -380,7 +380,7 @@ void draw_kuen_map() { for(int r=0; r<512; r++) for(int h=0; h<512; h++) { ld v = M_PI * (r+.5) / 512; - ld u = 2 * M_PI * (h+.5) / 512; + ld u = TAU * (h+.5) / 512; auto du = coord_derivative(point3(v,u,0), 0); auto dv = coord_derivative(point3(v,u,0), 1); auto n = hypot_d(3, du^dv); @@ -401,7 +401,7 @@ void draw_kuen_map() { for(auto p: rug::points) { auto hp = p->surface_point.params; int x = int(512 * hp[0] / M_PI); - int y = int(512 * hp[1] / 2 / M_PI); + int y = int(512 * hp[1] / TAU); qpixel(kuen_map, x, y) = 0xFF000000 | dexp_colors[p->dexp_id]; } @@ -431,7 +431,7 @@ void run_hyperlike() { int lim = (int) sqrt(rug::vertex_limit); for(int r=0; r void run_function(T f) { void run_other() { full_mesh(); - auto dp = at_zero(shape_origin(), spin(M_PI/2)); + auto dp = at_zero(shape_origin(), spin(90._deg)); int it = 0; for(auto p: rug::points) { diff --git a/textures.cpp b/textures.cpp index e6be9bdb..d0aba796 100644 --- a/textures.cpp +++ b/textures.cpp @@ -756,7 +756,7 @@ struct magic_param { void shuffle() { do_spin = hrand(2); spinangle = hrandf() - hrandf(); - moveangle = hrandf() * 2 * M_PI; + moveangle = hrandf() * TAU; shift = hrandf() - hrandf(); scale = hrandf() - hrandf(); proj = hrandf() - hrandf(); @@ -1565,7 +1565,7 @@ void splitseg(const shiftmatrix& A, const array& angles, const array mh = make_array(A * xpush0(mapeditor::dtwidth), A * xspinpush0(step, mapeditor::dtwidth), A * xspinpush0(-step, mapeditor::dtwidth)); auto mp = ptc(mh); @@ -1588,9 +1588,9 @@ void actDrawPixel(cell *c, shiftpoint h, color_t col) { hyperpoint h1 = inverse_shift(M * applyPatterndir(c, si), h); auto& tinf = config.texture_map[si.id]; for(auto& M2: tinf.matrices) for(int i = 0; itype; i += si.symmetries) { - fillcircle(M2 * spin(2 * M_PI * i / c->type) * h1, col); + fillcircle(M2 * spin(TAU * i / c->type) * h1, col); if(texturesym) - fillcircle(M2 * spin(2 * M_PI * i / c->type) * Mirror * h1, col); + fillcircle(M2 * spin(TAU * i / c->type) * Mirror * h1, col); } } catch(out_of_range&) {} diff --git a/usershapes.cpp b/usershapes.cpp index 0aeb2954..a256e9c1 100644 --- a/usershapes.cpp +++ b/usershapes.cpp @@ -45,13 +45,13 @@ void geometry_information::pushShape(usershapelayer& ds) { for(int r=0; r=0; i--) - hpcpush(T * spin(2*M_PI*r/ds.rots) * mirrortrans * ds.list[i]); + hpcpush(T * spin(TAU*r/ds.rots) * mirrortrans * ds.list[i]); } } diff --git a/util.cpp b/util.cpp index 96947a7b..e88d062f 100644 --- a/util.cpp +++ b/util.cpp @@ -230,7 +230,7 @@ cld exp_parser::parse(int prio) { force_eat(","); ld b = rparse(0); force_eat(")"); - res = edge_of_triangle_with_angles(2*M_PI/a, M_PI/b, M_PI/b); + res = edge_of_triangle_with_angles(TAU/a, M_PI/b, M_PI/b); } else if(eat("edge_angles(")) { cld a = rparse(0); @@ -253,7 +253,7 @@ cld exp_parser::parse(int prio) { force_eat(","); ld b = rparse(0); force_eat(")"); - res = edge_of_triangle_with_angles(M_PI/2, M_PI/a, M_PI/b); + res = edge_of_triangle_with_angles(90._deg, M_PI/a, M_PI/b); } #if CAP_ARCM else if(eat("arcmedge(")) { @@ -307,8 +307,7 @@ cld exp_parser::parse(int prio) { hyperpoint h = xpush(c) * spin(M_PI - 2*alpha) * xpush0(c); ld result = 2 * atan2(h); if(result < 0) result = -result; - while(result > 2 * M_PI) result -= 2 * M_PI; - if(result > M_PI) result = 2 * M_PI - result; + cyclefix(result, 0); res = result; }