1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-19 11:49:59 +00:00

namespace hyperpoint_vec removed

This commit is contained in:
Zeno Rogue 2019-08-09 14:03:43 +02:00
parent d77c44e48b
commit c131e21198
23 changed files with 67 additions and 157 deletions

View File

@ -30,7 +30,6 @@ vector<hyperpoint> geometry_information::get_shape(hpcshape sh) {
hyperpoint get_center(const vector<hyperpoint>& vh) {
hyperpoint h = Hypc;
using namespace hyperpoint_vec;
for(auto h1: vh) h = h + h1;
return normalize(h);
}
@ -124,7 +123,6 @@ void geometry_information::add_texture(hpcshape& sh) {
vector<hyperpoint> scaleshape(const vector<hyperpoint>& vh, ld s) {
vector<hyperpoint> res;
using namespace hyperpoint_vec;
for(hyperpoint h: vh) res.push_back(normalize(h * s + shcenter * (1-s)));
return res;
}
@ -542,7 +540,6 @@ void geometry_information::make_revolution_cut(hpcshape &sh, int each, ld push,
for(int i=0; i<n; i++) if(!stillin[i] && !stillin[lastid[i]]) lastid[i] = lastid[lastid[i]];
for(int i=0; i<n; i++) {
using namespace hyperpoint_vec;
if(!stillin[i]) gbody[i] = normalize(gbody[lastid[i]] * (i - lastid[i]) + gbody[nextid[i]] * (nextid[i] - i));
}
@ -609,7 +606,6 @@ void geometry_information::animate_bird(hpcshape& orig, hpcshape_animated& anima
void geometry_information::slimetriangle(hyperpoint a, hyperpoint b, hyperpoint c, ld rad, int lev) {
dynamicval<int> d(vid.texture_step, 8);
texture_order([&] (ld x, ld y) {
using namespace hyperpoint_vec;
ld z = 1-x-y;
ld r = scalefactor * hcrossf7 * (0 + pow(max(x,max(y,z)), .3) * 0.8);
hyperpoint h = rspintox(a*x+b*y+c*z) * xpush0(r);
@ -709,7 +705,6 @@ hyperpoint psmin(hyperpoint H) {
}
void geometry_information::adjust_eye(hpcshape& eye, hpcshape head, ld shift_eye, ld shift_head, int q, ld zoom) {
using namespace hyperpoint_vec;
hyperpoint center = Hypc;
for(int i=eye.s; i<eye.e; i++) if(q == 1 || hpc[i][1] > 0) center += hpc[i];
center = normalize(center);
@ -785,7 +780,6 @@ void queueball(const transmatrix& V, ld rad, color_t col, eItem what) {
auto line = [&] (transmatrix A, transmatrix B) {
hyperpoint h0 = A * xpush0(1);
hyperpoint h1 = B * xpush0(1);
using namespace hyperpoint_vec;
for(int i=0; i<=8; i++)
curvepoint(V1 * rspintox(normalize(h0*(8-i) + h1*i)) * xpush0(rad));
queuecurve(col, 0, PPR::LINE);
@ -899,7 +893,6 @@ void geometry_information::make_3d_models() {
hyperpoint front_leg = Hypc;
hyperpoint rear_leg = Hypc;
using namespace hyperpoint_vec;
for(int i=shDogFrontPaw.s; i<shDogFrontPaw.e; i++) front_leg += hpc[i];
for(int i=shDogRearPaw.s; i<shDogRearPaw.e; i++) rear_leg += hpc[i];
front_leg = normalize(front_leg);
@ -1178,7 +1171,6 @@ void geometry_information::make_3d_models() {
for(int t=0; t<S7; t++) {
dynamicval<int> dv(vid.texture_step, 16);
texture_order([&] (ld x, ld y) {
using namespace hyperpoint_vec;
ld z = 1-x-y;
ld rad = 2.1 - i * 0.2;
hyperpoint hx = ddi(t*12, -zhexf*rad) * C0;

View File

@ -428,7 +428,6 @@ namespace binary {
vector<hyperpoint> get_vertices(cell* c) override {
vector<hyperpoint> res;
ld yy = log(2) / 2;
using namespace hyperpoint_vec;
auto add = [&] (hyperpoint h) {
res.push_back(binary::parabolic3(h[0], h[1]) * xpush0(yy*h[2]));
};
@ -644,7 +643,6 @@ namespace binary {
// on which horocycle are we
ld horo_level(hyperpoint h) {
using namespace hyperpoint_vec;
h /= (1 + h[GDIM]);
h[0] -= 1;
h /= sqhypot_d(GDIM, h);
@ -653,7 +651,6 @@ namespace binary {
}
hyperpoint deparabolic3(hyperpoint h) {
using namespace hyperpoint_vec;
h /= (1 + h[3]);
hyperpoint one = point3(1,0,0);
h -= one;

View File

@ -1015,7 +1015,6 @@ vector<cell*> build_shortest_path(cell *c1, cell *c2) {
#endif
vector<cell*> p;
if(euclid) {
using namespace hyperpoint_vec;
p.push_back(c1);
hyperpoint h = tC0(calc_relative_matrix(c2, c1, C0));
cell *x = c1;

View File

@ -913,9 +913,6 @@ void centerrug(ld aspd) {
}
void cut_triangle2(const hyperpoint pa, const hyperpoint pb, const hyperpoint pc, const hyperpoint ha, const hyperpoint hb, const hyperpoint hc) {
using namespace hyperpoint_vec;
using hyperpoint_vec::operator *;
using hyperpoint_vec::operator +;
ld zac = pc[3] / (pc[3] - pa[3]);
hyperpoint pac = pa * zac + pc * (1-zac);
hyperpoint hac = ha * zac + hc * (1-zac);

View File

@ -126,7 +126,6 @@ bool is_behind(const hyperpoint& H) {
}
hyperpoint be_just_on_view(const hyperpoint& H1, const hyperpoint &H2) {
using namespace hyperpoint_vec;
// H1[2] * t + H2[2] * (1-t) == BEHIND_LIMIT - vid.alpha
// H2[2]- BEHIND_LIMIT + vid.alpha = t * (H2[2] - H1[2])
ld t = (H2[2] - BEHIND_LIMIT + vid.alpha) / (H2[2] - H1[2]);
@ -236,7 +235,6 @@ void addpoint(const hyperpoint& H) {
hyperpoint Hscr1;
band_shift += 2 * M_PI;
applymodel(H, Hscr1);
using namespace hyperpoint_vec;
if(hypot_d(2, Hlast-Hscr1) < hypot_d(2, Hlast-Hscr)) { Hscr = Hscr1; }
band_shift -= 4 * M_PI;
applymodel(H, Hscr1);
@ -312,7 +310,6 @@ void addpoly(const transmatrix& V, const vector<glvertex> &tab, int ofs, int cnt
if(correct_side(mid)) Hy = mid;
else Hx = mid;
}
using namespace hyperpoint_vec;
goodpoint = midz(Hy, goodpoint);
}
@ -561,7 +558,6 @@ void dqi_poly::gldraw() {
ld scale_at(const transmatrix& T) {
if(DIM == 3 && pmodel == mdPerspective) return 1 / abs((tC0(T))[2]);
if(sol) return 1;
using namespace hyperpoint_vec;
hyperpoint h1, h2, h3;
applymodel(tC0(T), h1);
applymodel(T * xpush0(.01), h2);
@ -582,7 +578,6 @@ ld linewidthat(const hyperpoint& h) {
}
}
else if(svg::in || inHighQual) {
using namespace hyperpoint_vec;
hyperpoint h0 = h / zlevel(h);
transmatrix T = rgpushxto0(h0);
return scale_at(T);
@ -839,7 +834,6 @@ void dqi_poly::draw() {
for(int j=0; j<MAX_PHASE; j++) {
twopoint_sphere_flips = j;
hyperpoint h2; applymodel(h1, h2);
using namespace hyperpoint_vec;
glvertex h = glhr::pointtogl(h2 * current_display->radius); h[1] *= vid.stretch;
if(i == 0)
phases[j].push_back(h);
@ -866,7 +860,6 @@ void dqi_poly::draw() {
// lin(a,b) is of form (x, 0, z)
int cpha = 0;
for(int i=0; i<cnt; i++) {
using namespace hyperpoint_vec;
hyperpoint h1 = V * glhr::gltopoint((*tab)[offset+i]);
hyperpoint mh1; applymodel(h1, mh1); mh1[1] *= vid.stretch;

View File

@ -177,7 +177,6 @@ void geometry_information::bshape2(hpcshape& sh, PPR prio, int shapeid, matrixli
}
hyperpoint lstmid = hpxyz(0,0,0);
using namespace hyperpoint_vec;
for(auto pp: lst) lstmid += pp;
transmatrix T = spin(-m.o.bspi);
while((spin(2*M_PI / rots) * T* lstmid)[0] < (T*lstmid)[0])
@ -226,7 +225,6 @@ void geometry_information::bshape_regular(floorshape &fsh, int id, int sides, in
if(binarytiling) {
const int STEP = vid.texture_step;
using namespace hyperpoint_vec;
for(int t=0; t<2; t++) {
@ -500,7 +498,6 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i
if(binarytiling)
for(int t=0; t<c->type; t++)
texture_order([&] (ld x, ld y) {
using namespace hyperpoint_vec;
hyperpoint left = binary::get_corner_horo_coordinates(c, t);
hyperpoint right = binary::get_corner_horo_coordinates(c, t+1);
hpcpush(orthogonal_move(binary::get_horopoint(left * x + right * y), dfloor_table[k]));
@ -511,7 +508,6 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i
int s = fsh.b[id].s;
int e = fsh.b[id].e-1;
for(int t=0; t<e-s; t++) {
using namespace hyperpoint_vec;
hyperpoint v1 = hpc[s+t] - C0;
hyperpoint v2 = hpc[s+t+1] - C0;
texture_order([&] (ld x, ld y) { hpcpush(orthogonal_move(normalize(C0 + v1 * x + v2 * y), dfloor_table[k])); });
@ -531,7 +527,6 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i
if(binarytiling)
for(int t=0; t<c->type; t++)
texture_order([&] (ld x, ld y) {
using namespace hyperpoint_vec;
hyperpoint left = binary::get_corner_horo_coordinates(c, t);
hyperpoint right = binary::get_corner_horo_coordinates(c, t+1);
hpcpush(orthogonal_move(binary::get_horopoint(left * x + right * y), top + h * (x+y)));
@ -542,7 +537,6 @@ void geometry_information::generate_floorshapes_for(int id, cell *c, int siid, i
int s = fsh.b[id].s;
int e = fsh.b[id].e-1;
for(int t=0; t<e-s; t++) {
using namespace hyperpoint_vec;
hyperpoint v1 = hpc[s+t] - C0;
hyperpoint v2 = hpc[s+t+1] - C0;
texture_order([&] (ld x, ld y) { hpcpush(orthogonal_move(normalize(C0 + v1 * x + v2 * y), top + h * (x+y))); });
@ -912,7 +906,6 @@ void draw_shape_for_texture(floorshape* sh) {
ftv.tvertices.clear();
ftv.texture_id = floor_textures->renderedTexture;
using namespace hyperpoint_vec;
hyperpoint center = eupush(gx, gy) * C0;
hyperpoint v1 = hpxyz3(0.25, 0.25, 0, 0);
hyperpoint v2 = hpxyz3(0.25, -0.25, 0, 0);

View File

@ -529,7 +529,6 @@ hyperpoint nearcorner(cell *c, int i) {
return neis[i];
}
if(penrose) {
using namespace hyperpoint_vec;
if(approx_nearcorner)
return kite::get_corner(c, i, 3) + kite::get_corner(c, i+1, 3) - C0;
else

View File

@ -490,7 +490,7 @@ namespace hr { namespace gp {
hyperpoint atz(const transmatrix& T, const transmatrix& corners, loc at, int cornerid = 6, ld cf = 3) {
int sp = 0;
again:
auto corner = corners * hyperpoint_vec::operator+ (loctoh_ort(at), hyperpoint_vec::operator/ (corner_coords[cornerid], cf));
auto corner = corners * (loctoh_ort(at) + (corner_coords[cornerid] / cf));
if(corner[1] < -1e-6 || corner[2] < -1e-6) {
at = at * eudir(1);
if(cornerid < SG6) cornerid = (1 + cornerid) % SG6;

View File

@ -766,7 +766,6 @@ transmatrix radar_transform;
pair<bool, hyperpoint> makeradar(hyperpoint h) {
if(GDIM == 3 && WDIM == 2) h = radar_transform * h;
using namespace hyperpoint_vec;
ld d = hdist0(h);
if(sol && nisot::geodesic_movement) {
@ -4489,7 +4488,6 @@ ld mousedist(transmatrix T) {
if(mouseaim_sensitivity) return sqhypot_d(2, T1) + (point_behind(T1) ? 1e10 : 0);
hyperpoint h1;
applymodel(T1, h1);
using namespace hyperpoint_vec;
h1 = h1 - hpxy((mousex - current_display->xcenter) / current_display->radius, (mousey - current_display->ycenter) / current_display->radius);
return sqhypot_d(2, h1) + (point_behind(T1) ? 1e10 : 0);
}
@ -4502,7 +4500,6 @@ void make_clipping_planes() {
clipping_planes.clear();
if(sphere) return;
auto add_clipping_plane = [] (ld x1, ld y1, ld x2, ld y2) {
using namespace hyperpoint_vec;
ld z1 = 1, z2 = 1;
hyperpoint sx = point3(y1 * z2 - y2 * z1, z1 * x2 - z2 * x1, x1 * y2 - x2 * y1);
sx /= hypot_d(3, sx);
@ -5051,7 +5048,6 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(just_gmatrix) return;
#if MAXMDIM >= 4
if(WDIM == 3 && pmodel == mdPerspective && !nil) {
using namespace hyperpoint_vec;
hyperpoint H = tC0(V);
for(hyperpoint& cpoint: clipping_planes) if((H|cpoint) < -sin_auto(cgi.corner_bonus)) {
drawcell_in_radar(c, V);
@ -5060,7 +5056,6 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
noclipped++;
}
if(pmodel == mdGeodesic && sol) {
using namespace hyperpoint_vec;
hyperpoint H = tC0(V);
if(abs(H[0]) <= 3 && abs(H[1]) <= 3 && abs(H[2]) <= 3 ) ;
else {
@ -5070,7 +5065,6 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
noclipped++;
}
if(pmodel == mdGeodesic && nil) {
using namespace hyperpoint_vec;
hyperpoint H = tC0(V);
if(abs(H[0]) <= 3 && abs(H[1]) <= 3 && abs(H[2]) <= 3 ) ;
else {
@ -7210,7 +7204,6 @@ void precise_mouseover() {
for(int i=0; i<mouseover->type; i++) {
hyperpoint h1 = get_corner_position(mouseover, (i+mouseover->type-1) % mouseover->type);
hyperpoint h2 = get_corner_position(mouseover, i);
using namespace hyperpoint_vec;
hyperpoint hx = r_mouseh - h1;
h2 = h2 - h1;
ld z = h2[1] * hx[0] - h2[0] * hx[1];

View File

@ -401,7 +401,6 @@ void draw_radar(bool cornermode) {
if(scompass) {
auto compassdir = [&] (char dirname, hyperpoint h) {
using namespace hyperpoint_vec;
h = nisot::local_perspective * h * .8;
queueline(atscreenpos(cx+rad * h[0], cy - rad * h[2] * si + rad * h[1] * co, 0)*C0, atscreenpos(cx+rad*h[0], cy - rad*h[2] * si, 0)*C0, 0xA0401040, -1);
displaychr(int(cx+rad * h[0]), int(cy - rad * h[2] * si + rad * h[1] * co), 0, 8, dirname, 0xA04010);

132
hyper.h
View File

@ -339,39 +339,85 @@ extern videopar vid;
extern array<ld, gGUARD> sightranges;
#define self (*this)
struct hyperpoint : array<ld, MAXMDIM> {
hyperpoint() {}
hyperpoint(ld x, ld y, ld z, ld w) {
(*this)[0] = x; (*this)[1] = y; (*this)[2] = z;
if(MAXMDIM == 4) (*this)[3] = w;
self[0] = x; self[1] = y; self[2] = z;
if(MAXMDIM == 4) self[3] = w;
}
inline hyperpoint& operator *= (ld d) {
for(int i=0; i<MDIM; i++) self[i] *= d;
return self;
}
inline hyperpoint& operator /= (ld d) {
for(int i=0; i<MDIM; i++) self[i] /= d;
return self;
}
inline hyperpoint& operator += (const hyperpoint h2) {
for(int i=0; i<MDIM; i++) self[i] += h2[i];
return self;
}
inline hyperpoint& operator -= (const hyperpoint h2) {
for(int i=0; i<MDIM; i++) self[i] -= h2[i];
return self;
}
inline friend hyperpoint operator * (ld d, hyperpoint h) { return h *= d; }
inline friend hyperpoint operator * (hyperpoint h, ld d) { return h *= d; }
inline friend hyperpoint operator / (hyperpoint h, ld d) { return h /= d; }
inline friend hyperpoint operator + (hyperpoint h, hyperpoint h2) { return h += h2; }
inline friend hyperpoint operator - (hyperpoint h, hyperpoint h2) { return h -= h2; }
// cross product
inline friend hyperpoint operator ^ (hyperpoint h1, hyperpoint h2) {
return hyperpoint(
h1[1] * h2[2] - h1[2] * h2[1],
h1[2] * h2[0] - h1[0] * h2[2],
h1[0] * h2[1] - h1[1] * h2[0],
0
);
}
// inner product
inline friend ld operator | (hyperpoint h1, hyperpoint h2) {
ld sum = 0;
for(int i=0; i<MDIM; i++) sum += h1[i] * h2[i];
return sum;
}
};
struct transmatrix {
ld tab[MAXMDIM][MAXMDIM];
hyperpoint& operator [] (int i) { return (hyperpoint&)tab[i][0]; }
const ld * operator [] (int i) const { return tab[i]; }
inline friend hyperpoint operator * (const transmatrix& T, const hyperpoint& H) {
hyperpoint z;
for(int i=0; i<MDIM; i++) {
z[i] = 0;
for(int j=0; j<MDIM; j++) z[i] += T[i][j] * H[j];
}
return z;
}
inline friend transmatrix operator * (const transmatrix& T, const transmatrix& U) {
transmatrix R;
for(int i=0; i<MDIM; i++) for(int j=0; j<MDIM; j++) {
R[i][j] = 0;
for(int k=0; k<MDIM; k++)
R[i][j] += T[i][k] * U[k][j];
}
return R;
}
};
inline hyperpoint operator * (const transmatrix& T, const hyperpoint& H) {
hyperpoint z;
for(int i=0; i<MDIM; i++) {
z[i] = 0;
for(int j=0; j<MDIM; j++) z[i] += T[i][j] * H[j];
}
return z;
}
inline transmatrix operator * (const transmatrix& T, const transmatrix& U) {
transmatrix R;
for(int i=0; i<MDIM; i++) for(int j=0; j<MDIM; j++) {
R[i][j] = 0;
for(int k=0; k<MDIM; k++)
R[i][j] += T[i][k] * U[k][j];
}
return R;
}
constexpr transmatrix diag(ld a, ld b, ld c, ld d) {
#if MAXMDIM==3
@ -411,52 +457,6 @@ inline hyperpoint point3(ld x, ld y, ld z) { return hyperpoint(x,y,z,0); }
inline hyperpoint point31(ld x, ld y, ld z) { return hyperpoint(x,y,z,1); }
inline hyperpoint point2(ld x, ld y) { return hyperpoint(x,y,0,0); }
namespace hyperpoint_vec {
inline hyperpoint& operator *= (hyperpoint& h, ld d) {
for(int i=0; i<MDIM; i++) h[i] *= d;
return h;
}
inline hyperpoint& operator /= (hyperpoint& h, ld d) {
for(int i=0; i<MDIM; i++) h[i] /= d;
return h;
}
inline hyperpoint operator += (hyperpoint& h, hyperpoint h2) {
for(int i=0; i<MDIM; i++) h[i] += h2[i];
return h;
}
inline hyperpoint operator -= (hyperpoint& h, hyperpoint h2) {
for(int i=0; i<MDIM; i++) h[i] -= h2[i];
return h;
}
inline hyperpoint operator * (ld d, hyperpoint h) { return h *= d; }
inline hyperpoint operator * (hyperpoint h, ld d) { return h *= d; }
inline hyperpoint operator / (hyperpoint h, ld d) { return h /= d; }
inline hyperpoint operator + (hyperpoint h, hyperpoint h2) { return h += h2; }
inline hyperpoint operator - (hyperpoint h, hyperpoint h2) { return h -= h2; }
// cross product
inline hyperpoint operator ^ (hyperpoint h1, hyperpoint h2) {
return hpxyz(
h1[1] * h2[2] - h1[2] * h2[1],
h1[2] * h2[0] - h1[0] * h2[2],
h1[0] * h2[1] - h1[1] * h2[0]
);
}
// inner product (in R^3)
inline ld operator | (hyperpoint h1, hyperpoint h2) {
ld sum = 0;
for(int i=0; i<MDIM; i++) sum += h1[i] * h2[i];
return sum;
}
}
extern int cellcount, heptacount;
// cell information for the game

View File

@ -228,13 +228,11 @@ hyperpoint normalize(hyperpoint H) {
// get the center of the line segment from H1 to H2
hyperpoint mid(const hyperpoint& H1, const hyperpoint& H2) {
using namespace hyperpoint_vec;
return normalize(H1 + H2);
}
// like mid, but take 3D into account
hyperpoint midz(const hyperpoint& H1, const hyperpoint& H2) {
using namespace hyperpoint_vec;
hyperpoint H3 = H1 + H2;
ld Z = 2;
@ -474,7 +472,6 @@ transmatrix rpushxto0(const hyperpoint& H) {
transmatrix ggpushxto0(const hyperpoint& H, ld co) {
if(translatable) {
using namespace hyperpoint_vec;
return eupush(co * H);
}
transmatrix res = Id;
@ -735,24 +732,20 @@ transmatrix rotmatrix(double rotation, int c0, int c1) {
}
hyperpoint mid3(hyperpoint h1, hyperpoint h2, hyperpoint h3) {
using namespace hyperpoint_vec;
return mid(h1+h2+h3, h1+h2+h3);
}
hyperpoint mid_at(hyperpoint h1, hyperpoint h2, ld v) {
using namespace hyperpoint_vec;
hyperpoint h = h1 * (1-v) + h2 * v;
return mid(h, h);
}
hyperpoint mid_at_actual(hyperpoint h, ld v) {
using namespace hyperpoint_vec;
return rspintox(h) * xpush0(hdist0(h) * v);
}
// in 3D, an orthogonal projection of C0 on the given triangle
hyperpoint orthogonal_of_C0(hyperpoint h0, hyperpoint h1, hyperpoint h2) {
using namespace hyperpoint_vec;
h0 /= h0[3];
h1 /= h1[3];
h2 /= h2[3];

View File

@ -149,7 +149,6 @@ ld find_zlev(hyperpoint& H) {
if(spatial_graphics) {
ld zlev = zlevel(H);
using namespace hyperpoint_vec;
if(zlev > 1-1e-6 && zlev < 1+1e-6) return 1;
H /= zlev;
return zlev;
@ -252,7 +251,6 @@ void make_twopoint(ld& x, ld& y) {
}
hyperpoint mobius(hyperpoint h, ld angle, ld scale = 1) {
using namespace hyperpoint_vec;
h = perspective_to_space(h * scale, 1, gcSphere);
h = rotmatrix(angle * degree, 1, 2) * h;
return space_to_perspective(h, 1) / scale;
@ -306,8 +304,6 @@ hyperpoint compute_hybrid(hyperpoint H, int rootid) {
void applymodel(hyperpoint H, hyperpoint& ret) {
using namespace hyperpoint_vec;
hyperpoint H_orig = H;
switch(pmodel) {
@ -1510,7 +1506,6 @@ void draw_model_elements() {
hyperpoint res = compute_hybrid(H, 2 | mode);
conformal::apply_orientation(res[0], res[1]);
conformal::apply_orientation_yz(res[2], res[1]);
using namespace hyperpoint_vec;
curvepoint(res * current_display->radius);
}
queuecurve(ringcolor, 0, PPR::CIRCLE);
@ -1582,7 +1577,6 @@ void draw_model_elements() {
void queuestraight(hyperpoint X, int style, color_t lc, color_t fc, PPR p) {
using namespace hyperpoint_vec;
hyperpoint H;
applymodel(X, H);
H *= current_display->radius;
@ -1640,7 +1634,6 @@ void draw_boundary(int w) {
for(int b=-1; b<=1; b+=2)
for(ld a=-90; a<=90+1e-6; a+=pow(.5, vid.linequality)) {
using namespace hyperpoint_vec;
ld x = sin(a * vid.twopoint_param * b / 90);
ld y = 0;
ld z = -sqrt(1 - x*x);
@ -1775,7 +1768,6 @@ void draw_boundary(int w) {
}
case mdSpiral: {
using namespace hyperpoint_vec;
if(euclid) return;
if(conformal::ring_not_spiral) return;
// if(p == PPR::CIRCLE) p = PPR::OUTCIRCLE;

View File

@ -37,7 +37,6 @@ ld inner(hyperpoint h1, hyperpoint h2) {
}
hyperpoint circumscribe(hyperpoint a, hyperpoint b, hyperpoint c) {
using namespace hyperpoint_vec;
hyperpoint h = C0;
b = b - a;
@ -207,7 +206,6 @@ int rearrange(bool total, ld minedge) {
int tooshort = 0;
for(int i=0; i<isize(cells); i++) {
auto& p1 = cells[i];
using namespace hyperpoint_vec;
hyperpoint h = Hypc;
for(auto v: p1.vertices) h = h + v;

View File

@ -1532,7 +1532,6 @@ namespace mapeditor {
ld dist = HUGE_VAL;
for(auto& layer: usershapes[sg][id]->d)
for(const hyperpoint& h: layer.list) {
using namespace hyperpoint_vec;
hyperpoint h1;
applymodel(drawtrans * h, h1);
ld d = sqhypot_d(2, h1 - onscr);

View File

@ -524,7 +524,6 @@ namespace nilv {
};
hyperpoint on_geodesic(hyperpoint s0, hyperpoint s1, ld x) {
using namespace hyperpoint_vec;
hyperpoint local = inverse(nisot::translate(s0)) * s1;
hyperpoint h = get_inverse_exp(local, 100);
return nisot::translate(s0) * formula_exp(h * x);
@ -551,7 +550,6 @@ namespace nisot {
}
void geodesic_step(hyperpoint& at, hyperpoint& velocity) {
using namespace hyperpoint_vec;
auto acc = christoffel(at, velocity, velocity);
auto at2 = at + velocity / 2;
@ -565,7 +563,6 @@ namespace nisot {
}
hyperpoint direct_exp(hyperpoint v, int steps) {
using namespace hyperpoint_vec;
hyperpoint at = point31(0, 0, 0);
v /= steps;
v[3] = 0;
@ -589,7 +586,6 @@ namespace nisot {
h = Pos * h;
int steps = 100;
using namespace hyperpoint_vec;
h /= steps;
auto tPos = transpose(Pos);

View File

@ -2179,7 +2179,6 @@ namespace linepatterns {
hyperpoint vh1 = V1 * h1;
hyperpoint vh2 = V2 * h2;
ld cros = vh1[0]*vh2[0] + vh1[1]*vh2[1] + vh1[2]*vh2[2];
using namespace hyperpoint_vec;
if(cros > 0)
gridline(V1, h1, V2, h2, col, par),
gridline(V1, -1*h1, V2, -1*h2, col, par);

View File

@ -44,7 +44,6 @@ void geometry_information::chasmifyPoly(double fac, double fac2, int k) {
last->flags |= POLY_TRIANGLES;
last->texture_offset = 0;
last->s = isize(hpc);
using namespace hyperpoint_vec;
auto at = [&] (ld x, ld y) {
x *= (isize(points) - 1);
int zf = int(x);
@ -121,7 +120,6 @@ void geometry_information::finishshape() {
if(area >= 0) last->flags |= POLY_INVERSE;
if(DIM == 3) {
using namespace hyperpoint_vec;
last->intester = Hypc;
for(int i=last->s; i<last->e; i++) last->intester += hpc[i];
if(last->s != last->e) last->intester /= last->e-last->s;
@ -689,7 +687,6 @@ void geometry_information::procedural_shapes() {
vector<ld> equal_weights(20, 1);
void geometry_information::make_wall(int id, vector<hyperpoint> vertices, vector<ld> weights) {
using namespace hyperpoint_vec;
// orient correctly
transmatrix T;
@ -745,18 +742,15 @@ void geometry_information::make_wall(int id, vector<hyperpoint> vertices, vector
}
vector<hyperpoint> make4(hyperpoint a, hyperpoint b, hyperpoint c) {
using namespace hyperpoint_vec;
return {a, b, b+c-a, c};
}
vector<hyperpoint> make5(hyperpoint a, hyperpoint b, hyperpoint c) {
using namespace hyperpoint_vec;
return {a, (a+b)/2, b, b+c-a, c};
}
void geometry_information::create_wall3d() {
if(WDIM == 2) return;
using namespace hyperpoint_vec;
int howmany = penrose ? 22 : S7;
shWall3D.resize(howmany);
shPlainWall3D.resize(howmany);
@ -875,7 +869,6 @@ void geometry_information::create_wall3d() {
}
if(DIM == 3 && euclid && S7 == 12) {
using namespace hyperpoint_vec;
auto v = euclid3::get_shifttable();
for(int w=0; w<12; w++) {
auto co = euclid3::getcoord(v[w]);
@ -889,7 +882,6 @@ void geometry_information::create_wall3d() {
}
if(DIM == 3 && euclid && S7 == 14) {
using namespace hyperpoint_vec;
auto v = euclid3::get_shifttable();
for(int w=0; w<14; w++) {
bshape(shWall3D[w], PPR::WALL);

View File

@ -49,8 +49,6 @@ namespace reg3 {
void generate() {
using namespace hyperpoint_vec;
if(S7 == 4) face = 3;
if(S7 == 6) face = 4;
if(S7 == 12) face = 5;

11
rug.cpp
View File

@ -79,7 +79,6 @@ bool rug_perspective = ISANDROID;
// such that inverse(M) * h1 = ( |h1|, 0, 0) and inverse(M) * h2 = ( .., .., 0)
transmatrix orthonormalize(hyperpoint h1, hyperpoint h2) {
using namespace hyperpoint_vec;
hyperpoint vec[3] = {h1, h2, h1 ^ h2};
@ -200,8 +199,6 @@ rugpoint *addRugpoint(hyperpoint h, double dist) {
m->y1 = (1 - onscreen[1] * vid.scale) / 2;
m->valid = false;
using namespace hyperpoint_vec;
if(euwrap && !bounded) {
hyperpoint h1 = eumove(torusconfig::sdx, torusconfig::sdy) * C0;
h1 /= sqhypot_d(2, h1);
@ -293,7 +290,6 @@ rugpoint *addRugpoint(hyperpoint h, double dist) {
}
rugpoint *findRugpoint(hyperpoint h) {
using namespace hyperpoint_vec;
for(int i=0; i<isize(points); i++)
if(sqhypot_d(rugdim, points[i]->h - h) < 1e-5) return points[i];
return NULL;
@ -718,7 +714,6 @@ bool force(rugpoint& m1, rugpoint& m2, double rd, bool is_anticusp=false, double
if(gwhere == gEuclid && fast_euclidean) {
return force_euclidean(m1, m2, rd, is_anticusp, d1, d2);
}
using namespace hyperpoint_vec;
normalizer n(m1.flat, m2.flat);
hyperpoint f1 = n(m1.flat);
hyperpoint f2 = n(m2.flat);
@ -756,7 +751,6 @@ void preset(rugpoint *m) {
int q = 0;
hyperpoint h;
for(int i=0; i<3; i++) h[i] = 0;
using namespace hyperpoint_vec;
preset_points.clear();
@ -891,7 +885,6 @@ void subdivide() {
rugpoint *mm = addRugpoint(mid(m->h, m2->h), (m->dist+m2->dist)/2);
halves[make_pair(m, m2)] = mm;
if(!good_shape) {
using namespace hyperpoint_vec;
normalizer n(m->flat, m2->flat);
hyperpoint h1 = n(m->flat);
hyperpoint h2 = n(m2->flat);
@ -1101,7 +1094,6 @@ void physics() {
bool use_precompute;
void getco(rugpoint *m, hyperpoint& h, int &spherepoints) {
using namespace hyperpoint_vec;
h = use_precompute ? m->getglue()->precompute : m->getglue()->flat;
if(rug_perspective && gwhere >= gSphere) {
if(h[2] > 0) {
@ -1141,7 +1133,6 @@ bool project_ods(hyperpoint azeq, hyperpoint& h1, hyperpoint& h2, bool eye) {
if(eye) tanalpha = -tanalpha;
if(!sphere) tanalpha = -tanalpha;
using namespace hyperpoint_vec;
ld d = hypot_d(3, azeq);
ld sindbd = sin_auto(d)/d, cosd = cos_auto(d);
@ -1190,7 +1181,6 @@ vector<glhr::ct_vertex> cp_array;
void drawTriangle(triangle& t) {
int num = t.m[2] ? 3 : 2;
using namespace hyperpoint_vec;
for(int i=0; i<num; i++) {
if(!t.m[i]->valid) return;
// if(t.m[i]->dist >= get_sightrange()+.51) return;
@ -1969,7 +1959,6 @@ void show() {
if(!camera_center) push_all_points(2, model_distance);
for(auto p:points) {
if(adjust_edges) for(auto& e: p->edges) e.len *= modelscale / last;
using namespace hyperpoint_vec;
if(adjust_points) p->flat *= modelscale / last;
enqueue(p);
}

View File

@ -1286,7 +1286,6 @@ void shootBullet(monster *m) {
bullet->pid = m->pid;
bullet->parenttype = m->type;
bullet->hitpoints = 0;
using namespace hyperpoint_vec;
bullet->inertia = cspin(0, WDIM-1, -M_PI/4 * i) * m->inertia;
bullet->inertia[frontdir()] += bullet_velocity(m->type) * SCALE;
additional.push_back(bullet);
@ -1815,7 +1814,6 @@ void movePlayer(monster *m, int delta) {
hyperpoint avg_inertia;
if(inertia_based && canmove) {
using namespace hyperpoint_vec;
avg_inertia = m->inertia;
ld coef = m->base->land == laWestWall ? 0.65 : falling ? 0.15 : 1;
coef /= 1000;
@ -1981,7 +1979,6 @@ void movePlayer(monster *m, int delta) {
if(!go || abs(playergo[cpid]) < 1e-3 || abs(playerturn[cpid]) > 1e-3) bulltime[cpid] = curtime;
if(!go) {
using namespace hyperpoint_vec;
playergo[cpid] = playergoturn[cpid] = playerstrafe[cpid] = 0;
if(WDIM == 3) playerturn[cpid] = playerturny[cpid] = 0;
if(falling) m->inertia = m->inertia * -1;
@ -2429,7 +2426,6 @@ void spawn_asteroids(monster *bullet, monster *target) {
hyperpoint bullet_inertia = inverse(target->pat) * bullet->pat * bullet->inertia;
for(int i=0; i<2; i++) {
using namespace hyperpoint_vec;
monster* child = new monster;
child->base = target->base;
child->at = target->at;

View File

@ -6,8 +6,6 @@
#if CAP_SURFACE
namespace hr { namespace surface {
using namespace hyperpoint_vec;
ld sech(ld d) { return 1 / cosh(d); }
string shape_name[] = { "hypersian rug", "tractricoid", "Dini's surface", "Kuen surface", "concave barrel",

View File

@ -462,7 +462,6 @@ void texture_config::finish_mapping() {
tinf3.texture_id = config.data.textureid;
if(isize(texture_map) && isize(texture_map.begin()->second.triangles)) {
auto& tris = texture_map.begin()->second.triangles;
using namespace hyperpoint_vec;
for(int a=0; a<8; a++) {
auto& tri = tris[a % isize(tris)];
@ -645,7 +644,6 @@ ld magic_quality() {
applymodel(ggmatrix(p.c) * p.cell_relative, inmodel);
inmodel[0] *= current_display->radius * 1. / current_display->scrsize;
inmodel[1] *= current_display->radius * 1. / current_display->scrsize;
using namespace hyperpoint_vec;
q += sqhypot_d(2, inmodel - p.texture_coords);
}
return q;