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