1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-20 12:20:01 +00:00

implemented a better system for logging and binary output

This commit is contained in:
Zeno Rogue 2018-11-24 17:01:49 +01:00
parent 0b09498ba1
commit 2fa265ac10
18 changed files with 374 additions and 339 deletions

View File

@ -2,7 +2,7 @@ namespace hr {
namespace arcm {
#define SDEBUG(x) if(debug_geometry) { doindent(); x; fflush(stdout); }
#define SDEBUG(x) if(debug_geometry) { x; fflush(stdout); }
static const int sfPH = 1;
static const int sfLINE = 2;
@ -563,16 +563,16 @@ void create_adjacent(heptagon *h, int d) {
if(euclid)
alt = encodeId(pair_to_vec(int(T[0][2]), int(T[1][2])));
SDEBUG( printf("look for: %p / %s\n", alt, display(T * C0)); )
SDEBUG( println(hlog, "look for: ", alt, " / ", T * C0); )
for(auto& p2: altmap[alt]) if(intval(p2.second * C0, T * C0) < 1e-4) {
SDEBUG( printf("cell found: %p\n", p2.first); )
SDEBUG( println(hlog, "cell found: ", p2.first); )
for(int d2=0; d2<p2.first->degree(); d2++) {
heptspin hs(p2.first, d2);
auto& t2 = current.get_triangle(p2.first, d2);
transmatrix T1 = T * spin(M_PI + t2.first);
SDEBUG( printf("compare: %s", display(T1 * xpush0(1))); )
SDEBUG( printf(":: %s\n", display(p2.second * xpush0(1))); )
SDEBUG( print(hlog, "compare: ", T1 * xpush0(1)); )
SDEBUG( println(hlog, ":: ", p2.second * xpush0(1)); )
if(intval(T1 * xpush0(1), p2.second * xpush0(1)) < 1e-4) {
// T1 = p2.second
@ -591,7 +591,7 @@ void create_adjacent(heptagon *h, int d) {
return;
}
}
SDEBUG( printf("but rotation not found\n"));
SDEBUG( println(hlog, "but rotation not found"));
}
auto& t2 = current.get_triangle(current.get_adj(hi));
@ -765,7 +765,7 @@ int readArgs() {
archimedean_tiling at;
shift(); at.parse(args());
if(at.errors) {
printf("error: %s\n", at.errormsg.c_str());
println(hlog, "error: ", at.errormsg);
}
else {
set_geometry(gArchimedean);
@ -1012,7 +1012,7 @@ void show() {
archimedean_tiling tested;
tested.parse(s);
if(tested.errors) {
printf("WARNING: %d errors on %s '%s'\n", tested.errors, s.c_str(), tested.errormsg.c_str());
println(hlog, "WARNING: ", tested.errors, " errors on ", s, " '", tested.errormsg, "'");
}
else {
tested.coloring = col;

View File

@ -26,6 +26,9 @@ charstyle& getcs(int id) {
return vid.cs;
}
void hread(hstream& hs, charstyle& cs) { hread_raw(hs, cs); }
void hwrite(hstream& hs, const charstyle& cs) { hwrite_raw(hs, cs); }
string csnameid(int id) {
if(id == 0) return XLAT("male");
if(id == 1) return XLAT("female");

View File

@ -348,13 +348,6 @@ namespace conformal {
llv = ticks;
phase = 0;
if(0)
for(int j=0; j<=Q; j++) {
hyperpoint cur = v[j]->at * C0;
printf("%4d/%3d. %p [%3d] %s\n", j, Q, v[j]->base, celldist(v[j]->base), display(cur));
}
}
void movetophase() {
@ -516,7 +509,7 @@ namespace conformal {
hyperpoint hscr;
applymodel(last, hscr);
ld bwidth = -current_display->radius * hscr[0];
printf("bwidth = %lf/%lf\n", bwidth, len);
print(hlog, "bwidth = ", bwidth, "/", len);
drawsegment:
SDL_Surface *gr = glbuf.render();

View File

@ -336,7 +336,7 @@ void debugScreen() {
dialog::addSelItem("celldistAlt", eubinary ? its(celldistAlt(mouseover)) : "--", 0);
dialog::addSelItem("temporary", its(mouseover->listindex), 0);
if(GOLDBERG)
dialog::addSelItem("whirl", gp::disp(gp::get_local_info(mouseover).relative), 0);
dialog::addSelItem("whirl", sprint(gp::get_local_info(mouseover).relative), 0);
if(archimedean)
dialog::addSelItem("ID", its(arcm::id_of(mouseover->master)), 0);
dialog::addBreak(50);

View File

@ -220,8 +220,8 @@ transmatrix calc_relative_matrix_help(cell *c, heptagon *h1) {
gm = gm * invheptmove[sp];
}
}
printf("OK\n");
display(gm * where);
println(hlog, "OK");
println(hlog, gm * where);
return gm * where;
}

View File

@ -133,22 +133,6 @@ namespace hr { namespace gp {
return goldberg_map[c.second&31][c.first&31];
}
const char *disp(loc at) {
static char bufs[16][16];
static int bufid;
bufid++; bufid %= 16;
snprintf(bufs[bufid], 16, "[%2d,%2d]", at.first, at.second);
return bufs[bufid];
}
const char *dcw(cellwalker cw) {
static char bufs[16][32];
static int bufid;
bufid++; bufid %= 16;
snprintf(bufs[bufid], 32, "[%p/%2d:%d:%d]", cw.at, cw.at?cw.at->type:-1, cw.spin, cw.mirrored);
return bufs[bufid];
}
int spawn;
cell*& peek(cellwalker cw) {
@ -177,7 +161,7 @@ namespace hr { namespace gp {
if(peek(wcw)) {
auto wcw1 = get_localwalk(wc1, dir1);
if(wcw + wstep != wcw1) {
WHD( Xprintf("%s : %s / %s (pull error from %s :: %s)\n", disp(at1), dcw(wcw+wstep), dcw(wcw1), disp(at), dcw(wcw)); )
WHD( println(hlog, at1, " : ", (wcw+wstep), " / ", wcw1, " (pull error from ", at, " :: ", wcw, ")") );
exit(1);
}
}
@ -185,7 +169,7 @@ namespace hr { namespace gp {
}
if(peek(wcw)) {
set_localwalk(wc1, dir1, wcw + wstep);
WHD( Xprintf("%s : %s (pulled from %s :: %s)\n", disp(at1), dcw(wcw + wstep), disp(at), dcw(wcw)); )
WHD( println(hlog, at1, " :", wcw+wstep, " (pulled from ", at, " :: ", wcw, ")"));
return true;
}
return false;
@ -195,12 +179,12 @@ namespace hr { namespace gp {
auto& wc = get_mapping(at);
auto wcw = get_localwalk(wc, dir);
auto& wc1 = get_mapping(at + eudir(dir));
WHD( Xprintf(" md:%02d s:%d", wc.mindir, wc.cw.spin); )
WHD( Xprintf(" connection %s/%d %s=%s ~ %s/%d ", disp(at), dir, dcw(wc.cw+dir), dcw(wcw), disp(at+eudir(dir)), dir1); )
WHD( print(hlog, format(" md:%02d s:%d", wc.mindir, wc.cw.spin)); )
WHD( print(hlog, " connection ", at, "/", dir, " ", wc.cw+dir, "=", wcw, " ~ ", at+eudir(dir), "/", dir1); )
if(!wc1.cw.at) {
wc1.start = wc.start;
if(peek(wcw)) {
WHD( Xprintf("(pulled) "); )
WHD( print(hlog, "(pulled) "); )
set_localwalk(wc1, dir1, wcw + wstep);
}
else {
@ -208,17 +192,17 @@ namespace hr { namespace gp {
wcw.at->c.setspin(wcw.spin, 0, false);
set_localwalk(wc1, dir1, wcw + wstep);
spawn++;
WHD( Xprintf("(created) "); )
WHD( print(hlog, "(created) "); )
}
}
WHD( Xprintf("%s ", dcw(wc1.cw+dir1)); )
auto wcw1 = get_localwalk(wc1, dir1);
if(peek(wcw)) {
if(wcw+wstep != wcw1) {
WHD( Xprintf("FAIL: %s / %s\n", dcw(wcw), dcw(wcw1)); exit(1); )
WHD( println(hlog, "FAIL: ", wcw, " / ", wcw1); exit(1); )
}
else {
WHD(Xprintf("(was there)\n");)
WHD( println(hlog, "(was there)\n");)
}
}
else {
@ -226,7 +210,7 @@ namespace hr { namespace gp {
peek(wcw) = wcw1.at;
wcw.at->c.setspin(wcw.spin, wcw1.spin, wcw.mirrored != wcw1.mirrored);
if(wcw+wstep != wcw1) {
Xprintf("assertion failed\n");
println(hlog, "assertion failed");
exit(1);
}
}
@ -241,7 +225,7 @@ namespace hr { namespace gp {
auto& ac0 = get_mapping(at);
ac0.cw = cellwalker(hs.at->c7, hs.spin, hs.mirrored);
ac0.start = at;
WHD( Xprintf("%s : %s\n", disp(at), dcw(ac0.cw)); )
WHD( println(hlog, at, " : ", dcw(ac0.cw)); )
return ac0;
}
@ -249,7 +233,7 @@ namespace hr { namespace gp {
WHD( Xprintf("EXTEND %p %d\n", c, d); )
if(c->master->c7 != c) {
while(c->master->c7 != c) {
WHD( Xprintf("%p direction 0 corresponds to %p direction %d\n", c, c->move(0), c->c.spin(0)); )
WHD( println(hlog, c, " direction 0 corresponds to ", c->move(0), " direction ", c->c.spinm(0)); )
d = c->c.spin(0);
c = c->move(0);
}
@ -335,11 +319,11 @@ namespace hr { namespace gp {
for(int i=0; i<S3; i++) {
loc start = vc[i];
loc end = vc[(i+1)%S3];
WHD( Xprintf("from %s to %s\n", disp(start), disp(end)); )
WHD( println(hlog, "from ", start, " to ", end); )
loc rel = param;
auto build = [&] (loc& at, int dx, bool forward) {
int dx1 = dx + SG2*i;
WHD( Xprintf("%s %d .. %s %d\n", disp(at), dx1, disp(at + eudir(dx1)), fixg6(dx1+SG3)); )
WHD( println(make_pair(hlog, at), " .. ", make_pair(at + eudir(dx1), fixg6(dx1+SG3))); )
conn(at, dx1);
if(forward) get_mapping(at).rdir = fixg6(dx1);
else get_mapping(at+eudir(dx1)).rdir = fixg6(dx1+SG3);
@ -383,7 +367,7 @@ namespace hr { namespace gp {
for(int k=0; k<SG6; k++)
if(start + eudir(k+SG2*i) == end)
build(start, k, true);
if(start != end) { Xprintf("assertion failed: start %s == end %s\n", disp(start), disp(end)); exit(1); }
if(start != end) { println(hlog, "assertion failed: start ", start, " == end ", end); exit(1); }
}
// now we can fill the interior of our big equilateral triangle
@ -395,7 +379,7 @@ namespace hr { namespace gp {
int dx = wc.rdir;
auto at1 = at + eudir(dx);
auto& wc1 = get_mapping(at1);
WHD( Xprintf("%s (%d) %s (%d)\n", disp(at), dx, disp(at1), wc1.rdir); )
WHD( println(make_pair(at, dx), " ", make_pair(at1, wc1.rdir)); )
int df = wc1.rdir - dx;
if(df < 0) df += SG6;
if(df == SG3) break;
@ -423,7 +407,7 @@ namespace hr { namespace gp {
break;
}
default:
Xprintf("case unhandled %d\n", df);
println(hlog, "case unhandled ", df);
exit(1);
}
else switch(df) {
@ -469,7 +453,7 @@ namespace hr { namespace gp {
}
}
WHD( Xprintf("DONE\n\n"); )
WHD( println(hlog, "DONE"); println(hlog); )
}
hyperpoint loctoh_ort(loc at) {
@ -600,7 +584,7 @@ namespace hr { namespace gp {
base_distlimit = SEE_ALL;
prepare_matrices();
if(debug_geometry)
Xprintf("scale = " LDF "\n", scale);
println(hlog, "scale = ", scale);
}
else {
alpha = 0;
@ -833,7 +817,7 @@ namespace hr { namespace gp {
found = true, centerloc = c;
}
if(!found && !quotient) {
Xprintf("Warning: centerloc not found: %d,%d,%d\n", dmain, d0, d1);
println(hlog, "Warning: centerloc not found: ", make_tuple(dmain, d0, d1));
}
center_locs[rel] = centerloc;
}
@ -859,7 +843,7 @@ namespace hr { namespace gp {
found = true, centerloc = c;
}
if(!found && !quotient) {
Xprintf("Warning: centerloc not found: %d,%d,%d,%d\n", dmain, d0, d1, dx);
println(hlog, "Warning: centerloc not found: ", make_tuple(dmain, d0, d1, dx));
}
center_locs[rel] = centerloc;
}

View File

@ -52,17 +52,6 @@ hstate transition(hstate s, int dir) {
return hsError;
}
/*
int indent = 0;
struct indenter {
indenter() { indent += 2; }
~indenter() { indent -= 2; }
};
template<class... T> auto iprintf(T... t) { for(int i=0; i<indent; i++) putchar(' '); return printf(t...); }
*/
#define COMPUTE -1000000
// create a new heptagon

188
hyper.h
View File

@ -3059,9 +3059,7 @@ extern transmatrix invheptmove[MAX_EDGE], invhexmove[MAX_EDGE];
// heptspin hsstep(const heptspin &hs, int spin);
extern void fixmatrix(transmatrix&);
void display(const transmatrix& T);
transmatrix rgpushxto0(const hyperpoint& H);
char *display(const hyperpoint& H);
string its(int i);
@ -3868,18 +3866,6 @@ bool score_loaded(int id);
int score_default(int id);
void handle_event(SDL_Event& ev);
#ifndef XPRINTF
#ifdef __GNUC__
__attribute__((__format__ (__printf__, 1, 2)))
#endif
inline void Xprintf(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
}
#endif
void pop_game();
void push_game();
void start_game();
@ -4153,18 +4139,174 @@ string bygen(reaction_t h);
void open_url(string s);
#endif
namespace mapstream {
extern FILE *f;
// HyperRogue streams
inline void saveChar(char c) { fwrite(&c, 1, 1, f); }
template<class T> void save(T& c) { fwrite(&c, sizeof(T), 1, f); }
struct hstream {
virtual void write_char(char c) = 0;
virtual void write_chars(const char* c, size_t q) { while(q--) write_char(*(c++)); }
virtual char read_char() = 0;
virtual void read_chars(char* c, size_t q) { while(q--) *(c++) = read_char(); }
inline char loadChar() { char c; int i=fread(&c, 1, 1, f); if(i!=1) return 0; else return c; }
template<class T> int load(T& c) { return fread(&c, sizeof(T), 1, f); }
inline int32_t loadInt() { int i; if(load(i) < 1) return -1; else return i; }
void saveString(const string& s);
string loadString();
template<class T> void write(const T& t) { hwrite(*this, t); }
template<class T> void read(T& t) { hread(*this, t); }
template<class T> T get() { T t; hread(*this, t); return t; }
template<class T> T get_raw() { T t; hread_raw(*this, t); return t; }
};
template<class T> void hwrite_raw(hstream& hs, const T& c) { hs.write_chars((char*) &c, sizeof(T)); }
template<class T> void hread_raw(hstream& hs, T& c) { hs.read_chars((char*) &c, sizeof(T)); }
template<class T, typename = typename std::enable_if<std::is_integral<T>::value || std::is_enum<T>::value>::type> void hwrite(hstream& hs, const T& c) { hwrite_raw(hs, c); }
template<class T, typename = typename std::enable_if<std::is_integral<T>::value || std::is_enum<T>::value>::type> void hread(hstream& hs, T& c) { hread_raw(hs, c); }
inline void hwrite(hstream& hs, const string& s) { hs.write_char(isize(s)); for(char c: s) hs.write_char(c); }
inline void hread(hstream& hs, string& s) { s = ""; int l = (unsigned char) hs.read_char(); for(int i=0; i<l; i++) s += hs.read_char(); }
inline void hwrite(hstream& hs, const ld& h) { double d = h; hs.write_chars((char*) &d, sizeof(double)); }
inline void hread(hstream& hs, ld& h) { double d; hs.read_chars((char*) &d, sizeof(double)); h = d; }
template<class T, size_t X> void hwrite(hstream& hs, const array<T, X>& a) { for(auto &ae: a) hwrite(hs, ae); }
template<class T, size_t X> void hread(hstream& hs, array<T, X>& a) { for(auto &ae: a) hread(hs, ae); }
template<class T> void hwrite(hstream& hs, const vector<T>& a) { hwrite<int>(hs, isize(a)); for(auto &ae: a) hwrite(hs, ae); }
template<class T> void hread(hstream& hs, vector<T>& a) { a.resize(hs.get<int>()); for(auto &ae: a) hread(hs, ae); }
template<class T, class U> void hwrite(hstream& hs, const map<T,U>& a) {
hwrite<int>(hs, isize(a)); for(auto &ae: a) hwrite(hs, ae.first, ae.second);
}
template<class T, class U> void hread(hstream& hs, map<T,U>& a) {
a.clear();
int N = hs.get<int>();
for(int i=0; i<N; i++) {
T key; hread(hs, key);
hread(hs, a[key]);
}
}
template<class C, class C1, class... CS> void hwrite(hstream& hs, const C& c, const C1& c1, const CS&... cs) { hwrite(hs, c); hwrite(hs, c1, cs...); }
template<class C, class C1, class... CS> void hread(hstream& hs, C& c, C1& c1, CS&... cs) { hread(hs, c); hread(hs, c1, cs...); }
struct hstream_exception : std::exception { hstream_exception() {} };
struct fhstream : hstream {
FILE *f;
virtual void write_char(char c) { write_chars(&c, 1); }
virtual void write_chars(char* c, size_t i) { if(fwrite(c, i, 1, f) != 1) throw hstream_exception(); }
virtual void read_chars(char* c, size_t i) { if(fread(c, i, 1, f) != 1) throw hstream_exception(); }
virtual char read_char() { char c; read_chars(&c, 1); return c; }
fhstream() { f = NULL; }
fhstream(const string pathname, const char *mode) { f = fopen(pathname.c_str(), mode); }
~fhstream() { if(f) fclose(f); }
};
struct shstream : hstream {
string s;
int pos;
shstream() { pos = 0; }
virtual void write_char(char c) { s += c; }
virtual char read_char() { if(pos == isize(s)) throw hstream_exception(); return s[pos++]; }
};
inline void print(hstream& hs) {}
template<class... CS> string sprint(const CS&... cs) { shstream hs; print(hs, cs...); return hs.s; }
template<class C, class C1, class... CS> void print(hstream& hs, const C& c, const C1& c1, const CS&... cs) { print(hs, c); print(hs, c1, cs...); }
template<class... CS> void println(hstream& hs, const CS&... cs) { print(hs, cs...); hs.write_char('\n'); }
// copied from: https://stackoverflow.com/questions/16387354/template-tuple-calling-a-function-on-each-element
namespace detail
{
template<int... Is>
struct seq { };
template<int N, int... Is>
struct gen_seq : gen_seq<N - 1, N - 1, Is...> { };
template<int... Is>
struct gen_seq<0, Is...> : seq<Is...> { };
template<typename T, typename F, int... Is>
void for_each(T&& t, F f, seq<Is...>)
{
auto l = { (f(std::get<Is>(t)), 0)... }; ignore(l);
}
}
template<typename... Ts, typename F>
void for_each_in_tuple(std::tuple<Ts...> const& t, F f)
{
detail::for_each(t, f, detail::gen_seq<sizeof...(Ts)>());
}
inline void print(hstream& hs, const string& s) { hs.write_chars(s.c_str(), isize(s)); }
inline void print(hstream& hs, int i) { print(hs, its(i)); }
inline void print(hstream& hs, ld x) { print(hs, fts(x)); }
struct comma_printer {
bool first;
hstream& hs;
template<class T> void operator() (const T& t) { if(first) first = false; else print(hs, ","); print(hs, t); }
comma_printer(hstream& hs) : first(true), hs(hs) {}
};
template<class T, size_t X> void print(hstream& hs, const array<T, X>& a) { print(hs, "("); comma_printer c(hs); for(const T& t: a) c(t); print(hs, ")"); }
template<class T> void print(hstream& hs, const vector<T>& a) { print(hs, "("); comma_printer c(hs); for(const T& t: a) c(t); print(hs, ")"); }
inline void print(hstream& hs, const hyperpoint h) { print(hs, (const array<ld, 3>&)h); }
inline void print(hstream& hs, const transmatrix T) {
print(hs, "("); comma_printer c(hs);
for(int i=0; i<3; i++)
for(int j=0; j<3; j++) c(T[i][j]);
print(hs, ")"); }
template<class T, class U> void print(hstream& hs, const pair<T, U> & t) { print(hs, "(", t.first, ",", t.second, ")"); }
template<class... T> void print(hstream& hs, const tuple<T...> & t) {
print(hs, "(");
comma_printer p(hs);
for_each_in_tuple(t, p);
print(hs, ")");
}
#ifndef SPECIAL_LOGGER
inline void special_log(char c) { putchar(c); }
#endif
struct logger : hstream {
int indentation;
virtual void write_char(char c) { special_log(c); if(c == 10) for(int i=0; i<indentation; i++) special_log(' '); }
virtual char read_char() { throw hstream_exception(); }
};
extern logger hlog;
#ifdef __GNUC__
__attribute__((__format__ (__printf__, 1, 2)))
#endif
inline string format(const char *fmt, ...) {
char buf[1000];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, 1000, fmt, ap);
va_end(ap);
return buf;
}
inline void print(hstream& hs, heptagon* h) { print(hs, format("H%p", h)); }
inline void print(hstream& hs, cell* h) { print(hs, format("C%p", h)); }
inline void print(hstream& hs, cellwalker cw) {
if(cw.at) print(hs, "[", cw.at, "/", cw.at->type, ":", cw.spin, ":", cw.mirrored, "]");
else print(hs, "[NULL]");
}
struct indenter {
dynamicval<int> ind;
indenter(int i = 2) : ind(hlog.indentation, hlog.indentation + (i)) {}
};
void appendHelp(string s);

View File

@ -179,13 +179,6 @@ ld zlevel(const hyperpoint &h) {
else return (h[2] < 0 ? -1 : 1) * sqrt(-intval(h, Hypc));
}
// display a hyperbolic point
char *display(const hyperpoint& H) {
static char buf[100];
sprintf(buf, "%8.4f:%8.4f:%8.4f", double(H[0]), double(H[1]), double(H[2]));
return buf;
}
ld hypot_auto(ld x, ld y) {
switch(cgclass) {
case gcEuclid:
@ -434,23 +427,6 @@ void fixmatrix(transmatrix& T) {
// show the matrix on screen
void display(const transmatrix& T) {
for(int y=0; y<3; y++) {
for(int x=0; x<3; x++) printf("%10.7f", double(T[y][x]));
printf(" -> %10.7f\n", double(squar(T[y][0]) + squar(T[y][1]) + sig(2) * squar(T[y][2])));
// printf("\n");
}
for(int x=0; x<3; x++) printf("%10.7f", double(squar(T[0][x]) + squar(T[1][x]) + sig(2) * squar(T[2][x])));
printf("\n");
for(int x=0; x<3; x++) {
int y = (x+1) % 3;
printf("%10.7f", double(T[0][x]*T[0][y] + T[1][x]*T[1][y] + sig(2) * T[2][x]*T[2][y]));
}
printf("\n\n");
}
ld det(const transmatrix& T) {
ld det = 0;
for(int i=0; i<3; i++)
@ -461,8 +437,7 @@ ld det(const transmatrix& T) {
}
void inverse_error(const transmatrix& T) {
printf("Warning: inverting a singular matrix\n");
display(T);
println(hlog, "Warning: inverting a singular matrix: ", T);
}
transmatrix inverse(const transmatrix& T) {

View File

@ -33,21 +33,18 @@
char android_log_buf[1000000];
int android_log_bufpos = 0;
#define XPRINTF
#pragma clang diagnostic ignored "-Wformat-security"
template<class...T>
// __attribute__((__format__ (__printf__, 1, 2)))
void Xprintf(const char *fmt, T... t) {
snprintf(android_log_buf+android_log_bufpos, 1000000-android_log_bufpos, fmt, t...);
int last_cr = 0;
int i;
for(i=0; android_log_buf[i]; i++) if(android_log_buf[i] == 10) {
android_log_buf[i] = 0;
__android_log_print(ANDROID_LOG_VERBOSE, "RUG", "%s", android_log_buf+last_cr);
last_cr = i+1;
#define SPECIAL_LOGGER
void special_log(char c) {
if(c == 10 || android_log_bufpos == 999999) {
android_log_buf[android_log_bufpos] = 0;
__android_log_print(ANDROID_LOG_VERBOSE, "HRLOG", "%s", android_log_buf);
android_log_bufpos = 0;
}
else {
android_log_buf[android_log_bufpos++] = c;
}
android_log_bufpos = 0;
while(i > last_cr) android_log_buf[android_log_bufpos++] = android_log_buf[last_cr++];
}
#include <jni.h>

View File

@ -74,34 +74,9 @@ namespace mapeditor {
#endif
}
namespace mapstream {
FILE *f;
void savePoint(const hyperpoint& h) {
for(int i=0; i<3; i++) { double x = h[i]; save(x); }
}
hyperpoint loadPoint() {
hyperpoint h;
for(int i=0; i<3; i++) { double x; load(x); h[i] = x; }
return h;
}
void saveString(const string& s) {
saveChar(isize(s));
for(char c: s) saveChar(c);
}
string loadString() {
string s;
int l = loadChar();
for(int i=0; i<l; i++) s += loadChar();
return s;
}
}
namespace mapstream {
#if CAP_EDIT
std::map<cell*, int> cellids;
vector<cell*> cellbyid;
vector<char> relspin;
@ -115,31 +90,31 @@ namespace mapstream {
}
bool saveMap(const char *fname) {
f = fopen(fname, "wb");
if(!f) return false;
int32_t i = VERNUM; save(i);
save(patterns::whichPattern);
save(geometry);
fhstream f(fname, "wb");
if(!f.f) return false;
int32_t i = VERNUM; f.write(i);
f.write(patterns::whichPattern);
f.write(geometry);
char nbtype = char(variation);
save(nbtype);
f.write(nbtype);
if(GOLDBERG) {
save(gp::param.first);
save(gp::param.second);
f.write(gp::param.first);
f.write(gp::param.second);
}
if(geometry == gTorus) {
save(torusconfig::qty);
save(torusconfig::dx);
save(torusconfig::dy);
f.write(torusconfig::qty);
f.write(torusconfig::dx);
f.write(torusconfig::dy);
}
if(geometry == gFieldQuotient) {
using namespace fieldpattern;
save(quotient_field_changed);
f.write(quotient_field_changed);
if(quotient_field_changed) {
save(current_extra);
save(fgeomextras[current_extra].current_prime_id);
f.write(current_extra);
f.write(fgeomextras[current_extra].current_prime_id);
}
}
if(geometry == gArchimedean) saveString(arcm::current.symbol);
if(geometry == gArchimedean) f.write(arcm::current.symbol);
addToQueue((bounded || euclid) ? currentmap->gamestart() : cwt.at->master->c7);
for(int i=0; i<isize(cellbyid); i++) {
cell *c = cellbyid[i];
@ -147,32 +122,32 @@ namespace mapstream {
for(int j=0; j<c->type; j++) if(c->move(j) && cellids.count(c->move(j)) &&
cellids[c->move(j)] < i) {
int32_t i = cellids[c->move(j)];
save(i);
saveChar(c->c.spin(j));
saveChar(j);
f.write(i);
f.write_char(c->c.spin(j));
f.write_char(j);
break;
}
}
saveChar(c->land);
saveChar(c->mondir);
saveChar(c->monst);
saveChar(c->wall);
// saveChar(c->barleft);
// saveChar(c->barright);
saveChar(c->item);
saveChar(c->mpdist);
// saveChar(c->bardir);
save(c->wparam); save(c->landparam);
saveChar(c->stuntime); saveChar(c->hitpoints);
f.write_char(c->land);
f.write_char(c->mondir);
f.write_char(c->monst);
f.write_char(c->wall);
// f.write_char(c->barleft);
// f.write_char(c->barright);
f.write_char(c->item);
f.write_char(c->mpdist);
// f.write_char(c->bardir);
f.write(c->wparam); f.write(c->landparam);
f.write_char(c->stuntime); f.write_char(c->hitpoints);
for(int j=0; j<c->type; j++) {
cell *c2 = c->move(j);
if(c2 && c2->land != laNone) addToQueue(c2);
}
}
printf("cells saved = %d\n", isize(cellbyid));
int32_t n = -1; save(n);
int32_t n = -1; f.write(n);
int32_t id = cellids.count(cwt.at) ? cellids[cwt.at] : -1;
save(id);
f.write(id);
for(int i=0; i<mapeditor::USERSHAPEGROUPS; i++) for(auto usp: usershapes[i]) {
usershape *us = usp.second;
@ -180,16 +155,15 @@ namespace mapstream {
for(int l=0; l<USERLAYERS; l++) if(isize(us->d[l].list)) {
usershapelayer& ds(us->d[l]);
save(i); save(usp.first); save(l); save(ds.sym); save(ds.rots); save(ds.color);
n = isize(ds.list); save(n);
savePoint(ds.shift);
savePoint(ds.spin);
for(int i=0; i<isize(ds.list); i++) savePoint(ds.list[i]);
f.write(i); f.write(usp.first); f.write(l); f.write(ds.sym); f.write(ds.rots); f.write(ds.color);
n = isize(ds.list); f.write(n);
f.write(ds.shift);
f.write(ds.spin);
for(int i=0; i<isize(ds.list); i++) f.write(ds.list[i]);
}
}
n = -1; save(n);
n = -1; f.write(n);
fclose(f);
cellids.clear();
cellbyid.clear();
return true;
@ -203,38 +177,38 @@ namespace mapstream {
}
bool loadMap(const string& fname) {
f = fopen(fname.c_str(), "rb");
if(!f) return false;
fhstream f(fname, "rb");
if(!f.f) return false;
clearMemory();
int vernum = loadInt();
if(vernum >= 7400) load(patterns::whichPattern);
int vernum = f.get<int>();
if(vernum >= 7400) f.read(patterns::whichPattern);
if(vernum >= 10203) {
load(geometry);
f.read(geometry);
char nbtype;
load(nbtype);
f.read(nbtype);
variation = eVariation(nbtype);
if(GOLDBERG) {
load(gp::param.first);
load(gp::param.second);
f.read(gp::param.first);
f.read(gp::param.second);
}
if(geometry == gTorus) {
load(torusconfig::qty);
load(torusconfig::dx);
load(torusconfig::dy);
f.read(torusconfig::qty);
f.read(torusconfig::dx);
f.read(torusconfig::dy);
}
if(geometry == gFieldQuotient) {
using namespace fieldpattern;
load(quotient_field_changed);
f.read(quotient_field_changed);
if(quotient_field_changed) {
load(current_extra);
load(fgeomextras[current_extra].current_prime_id);
f.read(current_extra);
f.read(fgeomextras[current_extra].current_prime_id);
enableFieldChange();
}
}
if(geometry == gArchimedean) {
string& symbol = arcm::current.symbol;
symbol = loadString();
symbol = f.get<string>();
arcm::current.parse();
if(arcm::current.errors > 0) {
printf("Errors! %s\n", arcm::current.errormsg.c_str());
@ -256,48 +230,48 @@ namespace mapstream {
rspin = 0;
}
else {
int32_t parent = loadInt();
int32_t parent = f.get<int>();
if(parent<0 || parent >= isize(cellbyid)) break;
int dir = loadChar();
int dir = f.read_char();
cell *c2 = cellbyid[parent];
dir = fixspin(dir, relspin[parent], c2->type);
c = createMov(c2, dir);
// printf("%p:%d,%d -> %p\n", c2, relspin[parent], dir, c);
// spinval becomes xspinval
rspin = (c2->c.spin(dir) - loadChar() + MODFIXER) % c->type;
rspin = (c2->c.spin(dir) - f.read_char() + MODFIXER) % c->type;
}
cellbyid.push_back(c);
relspin.push_back(rspin);
c->land = (eLand) loadChar();
c->mondir = fixspin(rspin, loadChar(), c->type);
c->monst = (eMonster) loadChar();
c->wall = (eWall) loadChar();
// c->barleft = (eLand) loadChar();
// c->barright = (eLand) loadChar();
c->item = (eItem) loadChar();
c->mpdist = loadChar();
c->land = (eLand) f.read_char();
c->mondir = fixspin(rspin, f.read_char(), c->type);
c->monst = (eMonster) f.read_char();
c->wall = (eWall) f.read_char();
// c->barleft = (eLand) f.read_char();
// c->barright = (eLand) f.read_char();
c->item = (eItem) f.read_char();
c->mpdist = f.read_char();
c->bardir = NOBARRIERS;
// fixspin(rspin, loadChar(), c->type);
// fixspin(rspin, f.read_char(), c->type);
if(vernum < 7400) {
short z;
load(z);
f.read(z);
c->wparam = z;
}
else load(c->wparam);
load(c->landparam);
else f.read(c->wparam);
f.read(c->landparam);
// backward compatibility
if(vernum < 7400 && !isIcyLand(c->land)) c->landparam = HEAT(c);
c->stuntime = loadChar();
c->hitpoints = loadChar();
c->stuntime = f.read_char();
c->hitpoints = f.read_char();
if(patterns::whichPattern)
mapeditor::modelcell[patterns::getpatterninfo0(c).id] = c;
}
int32_t whereami = loadInt();
int32_t whereami = f.get<int>();
if(whereami >= 0 && whereami < isize(cellbyid))
cwt.at = cellbyid[whereami];
else cwt.at = currentmap->gamestart();
@ -330,24 +304,24 @@ namespace mapstream {
cheater = 1;
if(vernum >= 7400) while(true) {
int i = loadInt();
int i = f.get<int>();
if(i == -1) break;
int j = loadInt(), l = loadInt();
int j = f.get<int>(), l = f.get<int>();
if(i<0 || i >= mapeditor::USERSHAPEGROUPS) break;
if(l<0 || l >= USERLAYERS) break;
initShape(i, j);
usershapelayer& ds(usershapes[i][j]->d[l]);
load(ds.sym); load(ds.rots); load(ds.color);
f.read(ds.sym); f.read(ds.rots); f.read(ds.color);
ds.list.clear();
int siz = loadInt();
int siz = f.get<int>();
ds.shift = loadPoint();
ds.spin = loadPoint();
ds.shift = f.get<hyperpoint>();
ds.spin = f.get<hyperpoint>();
for(int i=0; i<siz; i++)
ds.list.push_back(loadPoint());
ds.list.push_back(f.get<hyperpoint>());
}
buildpolys();

View File

@ -360,8 +360,7 @@ namespace hr { namespace netgen {
if(0) if((i==0 && e == 0) || (i == zeroi && e == zeroe)) {
for(int ofs=0; ofs<t; ofs++) {
printf("OFS %d: %s", ofs, display(hvec(i, (e+ofs)%t)));
printf(" %s\n", display(hvec(i, (e+1+ofs)%t)));
println(hlog, "OFS ", ofs, hvec(i, (e+ofs)%t), hvec(i, (e+1+ofs)%t));
}
}
@ -410,7 +409,7 @@ namespace hr { namespace netgen {
}
}
printf("pateks = %d\n", pateks);
println(hlog, "pateks = ", pateks);
IMAGESAVE(net, "papermodel-all" IMAGEEXT);
IMAGESAVE(hqsurface, "papermodel-source" IMAGEEXT);

View File

@ -183,7 +183,7 @@ void run_snub(int v, int w) {
xts0 = tC0(ts[0]);
printf("original %s\n", display(xts0));
println(hlog, "original ", xts0);
cor = rel * gmatrix[cc] * C0;

View File

@ -1210,122 +1210,110 @@ bool handleMenu(int sym, int uni) {
return false;
}
void saveFloat(float x) { mapstream::save(x); }
float loadFloat() { float x; mapstream::load(x); return x; }
void save_compressed(string name) {
// save everything in compressed form
mapstream::f = fopen(name.c_str(), "wb");
if(!mapstream::f) {
fhstream f(name, "wb");
if(!f.f) {
printf("failed to open for save_compressed: %s\n", name.c_str());
return;
}
// save columns
mapstream::save(columns);
for(int i=0; i<columns; i++) mapstream::saveString(colnames[i]);
for(int i=0; i<columns; i++) saveFloat(weights[i]);
f.write(columns);
for(int i=0; i<columns; i++) f.write(colnames[i]);
for(int i=0; i<columns; i++) hwrite_raw<float>(f, weights[i]);
// save neurons
int N = isize(net);
mapstream::save(N);
for(int i=0; i<N; i++)
for(int j=0; j<columns; j++) saveFloat(net[i].net[j]);
f.write<int>(isize(net));
for(int i=0; i<isize(net); i++)
for(int j=0; j<columns; j++) hwrite_raw<float>(f, net[i].net[j]);
// save shown samples
map<int, int> saved_id;
int ss = isize(sample_vdata_id);
mapstream::save(ss);
f.write<int>(isize(sample_vdata_id));
int index = 0;
for(auto p: sample_vdata_id) {
int i = p.first;
for(int j=0; j<columns; j++) saveFloat(data[i].val[j]);
mapstream::saveString(data[i].name);
for(int j=0; j<columns; j++) hwrite_raw<float>(f, data[i].val[j]);
f.write(data[i].name);
int id = p.second;
saved_id[id] = index++;
auto& vd = vdata[id];
mapstream::save(vd.cp);
hwrite_raw(f, vd.cp);
}
// save edge types
int qet = isize(edgetypes);
mapstream::save(qet);
f.write<int>(isize(edgetypes));
for(auto&et: edgetypes) {
mapstream::saveString(et->name);
saveFloat(et->visible_from);
mapstream::save(et->color);
f.write(et->name);
hwrite_raw<float>(f, et->visible_from);
f.write(et->color);
}
// save edge infos
int qei = isize(edgeinfos);
mapstream::save(qei);
f.write<int>(isize(edgeinfos));
for(auto& ei: edgeinfos) {
for(int x=0; x<isize(edgetypes); x++)
if(ei->type == &*edgetypes[x]) mapstream::saveChar(x);
mapstream::save(saved_id[ei->i]);
mapstream::save(saved_id[ei->j]);
saveFloat(ei->weight);
if(ei->type == &*edgetypes[x]) f.write_char(x);
f.write(saved_id[ei->i]);
f.write(saved_id[ei->j]);
hwrite_raw<float>(f, ei->weight);
}
fclose(mapstream::f);
}
void load_compressed(string name) {
// save everything in compressed form
mapstream::f = fopen(name.c_str(), "rb");
if(!mapstream::f) {
fhstream f(name, "rb");
if(!f.f) {
printf("failed to open for load_compressed: %s\n", name.c_str());
return;
}
// load columns
mapstream::load(columns);
f.read(columns);
colnames.resize(columns);
for(int i=0; i<columns; i++) colnames[i] = mapstream::loadString();
for(int i=0; i<columns; i++) f.read(colnames[i]);
alloc(weights);
for(int i=0; i<columns; i++) weights[i] = loadFloat();
for(int i=0; i<columns; i++) weights[i] = f.get_raw<float>();
samples = 0; sominit(1, true);
// load neurons
int N = mapstream::loadInt();
int N = f.get<int>();
if(cells != N) {
fprintf(stderr, "Error: bad number of cells (N=%d c=%d)\n", N, cells);
exit(1);
}
for(neuron& n: net)
for(int k=0; k<columns; k++)
n.net[k] = loadFloat();
n.net[k] = f.get_raw<float>();
// load data
samples = mapstream::loadInt();
samples = f.get<int>();
data.resize(samples);
int id = 0;
for(auto& d: data) {
alloc(d.val);
for(int j=0; j<columns; j++) {
float x;
mapstream::load(x);
d.val[j] = x;
}
d.name = mapstream::loadString();
for(int j=0; j<columns; j++)
d.val[j] = f.get_raw<float>();
f.read(d.name);
int i = vdata.size();
sample_vdata_id[id] = i;
vdata.emplace_back();
auto& v = vdata.back();
v.name = data[i].name;
mapstream::load(v.cp);
hread_raw(f, v.cp);
createViz(i, cwt.at, Id);
v.m->store();
id++;
}
// load edge types
int qet = mapstream::loadInt();
int qet = f.get<int>();
for(int i=0; i<qet; i++) {
auto et = add_edgetype(mapstream::loadString());
et->visible_from = loadFloat();
mapstream::load(et->color);
auto et = add_edgetype(f.get<string>());
et->visible_from = f.get_raw<float>();
f.read(et->color);
}
// load edge infos
int qei = mapstream::loadInt();
int qei = f.get<int>();
for(int i=0; i<qei; i++) {
auto t = edgetypes[mapstream::loadChar()];
int ei = mapstream::loadInt();
int ej = mapstream::loadInt();
float w = loadFloat();
auto t = edgetypes[f.read_char()];
int ei = f.get<int>();
int ej = f.get<int>();
float w = f.get_raw<float>();
addedge(ei, ej, w, true, &*t);
}
fclose(mapstream::f);
analyze();
}

View File

@ -173,11 +173,11 @@ void run_snub(int v, int w) {
for(auto p: sideangles) sav.push_back(p.first);
sort(sav.begin(), sav.end());
printf("sideangles "); for(int i=0; i<3; i++) printf("%lf ", double(sav[i])); printf("\n");
println(hlog, "sideangles ", sav);
xts0 = tC0(ts[0]);
printf("original %s\n", display(xts0));
println(hlog, "original ", xts0);
cor = rel * gmatrix[cc] * C0;

37
rug.cpp
View File

@ -95,7 +95,7 @@ transmatrix orthonormalize(hyperpoint h1, hyperpoint h2) {
hyperpoint azeq_to_hyperboloid(hyperpoint h) {
if(abs(h[2])>1e-4) {
Xprintf("Error: h[2] = %lf\n", h[2]);
println(hlog, "Error: h[2] = ", h[2]);
rug_failure = true;
}
if(euclid) {
@ -415,7 +415,7 @@ void buildTorusRug() {
ld xfactor = 0, yfactor = 0;
Xprintf("factor = %lf\n", factor);
println(hlog, "factor = ", factor);
if(factor <= 2.05) factor = 2.2;
factor -= 1;
@ -439,10 +439,10 @@ void buildTorusRug() {
ld xscale = hypot(xfactor * xh[0] * 2 * M_PI, yfactor * xh[1] * 2 * M_PI);
ld yscale = hypot(xfactor * yh[0] * 2 * M_PI, yfactor * yh[1] * 2 * M_PI);
printf("xh = %s\n", display(xh));
printf("yh = %s\n", display(yh));
printf("factor = %lf %lf (%lf)\n", double(xfactor), double(yfactor), factor);
printf("scales = %fl %lf\n", double(xscale), double(yscale));
println(hlog, "xh = ", xh);
println(hlog, "yh = ", yh);
println(hlog, "factor = ", make_tuple(xfactor, yfactor, factor));
println(hlog, "scales = ", make_tuple(xscale, yscale));
modelscale = xscale / crossf;
}
@ -536,7 +536,7 @@ void buildTorusRug() {
qvalid = 0;
for(auto p: points) if(!p->glue) qvalid++;
Xprintf("qvalid = %d\n", qvalid);
println(hlog, "qvalid = ", qvalid);
if(rug_perspective)
push_all_points(2, -model_distance);
@ -558,11 +558,11 @@ void verify() {
ratios.push_back(l0 / l);
}
Xprintf("%s", "Length verification:\n");
println(hlog, "Length verification:");
sort(ratios.begin(), ratios.end());
for(int i=0; i<isize(ratios); i += isize(ratios) / 10)
Xprintf("%lf\n", ratios[i]);
Xprintf("%s", "\n");
println(hlog, ratios[i]);
println(hlog);
}
void comp(cell*& minimum, cell *next) {
@ -618,7 +618,7 @@ void buildRug() {
catch(out_of_range&) {}
}
Xprintf("vertices = %d triangles= %d\n", isize(points), isize(triangles));
println(hlog, "vertices = ", isize(points), " triangles= ", isize(triangles));
if(subdivide_first)
for(int i=0; i<20 && subdivide_further(); i++)
@ -821,17 +821,17 @@ void subdivide() {
// if(euclid && gwhere == gEuclid) return;
if(!subdivide_further()) {
if(euclid && !bounded && gwhere == gEuclid) {
Xprintf("%s", "Euclidean -- full precision\n");
println(hlog, "Euclidean -- full precision");
stop = true;
}
else {
err_zero_current /= 2;
Xprintf("increasing precision to %lg\n", err_zero_current);
println(hlog, "increasing precision to ", err_zero_current);
for(auto p: points) enqueue(p);
}
return;
}
Xprintf("subdivide (%d,%d)\n", N, isize(triangles));
println(hlog, "subdivide ", make_pair(N, isize(triangles)));
need_mouseh = true;
divides++;
vector<triangle> otriangles = triangles;
@ -866,8 +866,7 @@ void subdivide() {
calcLengths();
Xprintf("result (%d,%d)\n", isize(points), isize(triangles));
println(hlog, "result ", make_tuple(isize(points), isize(triangles)));
}
ld slow_modeldist(const hyperpoint& h1, const hyperpoint& h2) {
@ -953,7 +952,7 @@ int detect_cusps() {
max_edge_length = max(max_edge_length, e.len);
anticusp_dist = anticusp_factor * max_edge_length;
int stats[3] = {0,0,0};
array<int, 3> stats = {0,0,0};
map<bincode, vector<rugpoint*> > code_to_point;
for(auto p: points) if(p->valid)
@ -983,7 +982,7 @@ int detect_cusps() {
printf("cusp stats: %d/%d/%d | %d/%d/%d\n", stats[0], stats[1], stats[2], stats2[0], stats2[1], stats2[2]); */
Xprintf("cusp stats: %d/%d/%d\n", stats[0], stats[1], stats[2]);
println(hlog, "cusp stats: ", stats);
return stats[2];
}
@ -1014,7 +1013,7 @@ void addNewPoints() {
enqueue(&m);
}
}
if(qvalid != oqvalid) { Xprintf("adding new points %4d %4d %4d %.9lf %9d %9d\n", oqvalid, qvalid, isize(points), dist, dt, queueiter); }
if(qvalid != oqvalid) { println(hlog, "adding new points ", make_tuple(oqvalid, qvalid, isize(points), dist, dt, queueiter)); }
}
void physics() {

View File

@ -283,40 +283,41 @@ transmatrix create_M_matrix(hyperpoint zero, hyperpoint v1) {
transmatrix M = build_matrix(v1, v2, Hypc);
display(M);
println(hlog, M);
printf("M matrix test: %lf %lf %lf %lf\n", hypot3(T*M*unit_vector[0]), hypot3(T*M*unit_vector[1]), hypot3(T*M*(unit_vector[0]+unit_vector[1])),
((T*M*unit_vector[0]) | (T*M*unit_vector[1])));
println(hlog, "M matrix test: ",
make_tuple(hypot3(T*M*unit_vector[0]), hypot3(T*M*unit_vector[1]), hypot3(T*M*(unit_vector[0]+unit_vector[1])),
((T*M*unit_vector[0]) | (T*M*unit_vector[1]))));
return M;
}
dexp_origin at_zero(hyperpoint zero, transmatrix start) {
printf("zero = %s\n", display(zero));
println(hlog, "zero = ", zero);
printf("curvature at zero = %lf\n", compute_curvature(zero));
printf("curvature at X1 = %lf\n", compute_curvature(zero + hpxyz(.3, 0, 0)));
printf("curvature at X2 = %lf\n", compute_curvature(zero + hpxyz(0, .3, 0)));
printf("curvature at X3 = %lf\n", compute_curvature(zero + hpxyz(.4, .3, 0)));
println(hlog, "curvature at zero = ", compute_curvature(zero));
println(hlog, "curvature at X1 = ", compute_curvature(zero + hpxyz(.3, 0, 0)));
println(hlog, "curvature at X2 = ", compute_curvature(zero + hpxyz(0, .3, 0)));
println(hlog, "curvature at X3 = ", compute_curvature(zero + hpxyz(.4, .3, 0)));
return {start, create_M_matrix(zero, unit_vector[0]), zero};
}
dexp_origin at_other(dexp_origin& o1, hyperpoint h) {
printf("\n\nmapping %s...\n", display(h));
display(o1.H); display(o1.M);
println(hlog, "\n\nmapping ", h, "...");
println(hlog, o1.H, o1.M);
auto dd = map_to_surface(h, o1);
hyperpoint newzero = dd.params;
printf("error = %lf\n", dd.remaining_distance);
println(hlog, "error = ", dd.remaining_distance);
transmatrix Spin = spintox(o1.H * h);
transmatrix T = pushxto0(Spin * o1.H * h) * Spin;
printf("h is = %s\n", display(h));
printf("T*c0 is = %s\n", display(T * C0));
printf("T*h is = %s\n", display(T * o1.H * h));
println(hlog, "h is = ", h);
println(hlog, "T*c0 is = ", T * C0);
println(hlog, "T*h is = ", T * o1.H * h);
return {T * o1.H, create_M_matrix(newzero, dd.cont), newzero};
}
@ -388,7 +389,7 @@ void draw_kuen_map() {
px = 0xFF000000 + (((int)(n*255/nmax)) * (kuen_branch(v,u) == 1 ? 0x10101 : 0x10001));
}
}
printf("nmax = %lf\n", nmax);
println(hlog, "nmax = ", nmax);
}
for(auto p: rug::points) {
@ -635,7 +636,7 @@ void run_shape(eShape s) {
rug::qvalid++;
}
printf("minx = %lf maxx = %lf\n", minx, maxx);
println(hlog, "minx = ", minx, " maxx = ", maxx);
ld shift = -(minx + maxx) / 2;
for(auto p: rug::points) if(p->valid)

View File

@ -140,17 +140,6 @@ bool appears(const string& haystack, const string& needle) {
return simplify(haystack).find(simplify(needle)) != string::npos;
}
/* indenter */
int current_indentation;
struct indenter {
indenter() { current_indentation += 2; }
~indenter() { current_indentation -= 2; }
};
void doindent() { for(int i=0; i<current_indentation; i++) printf(" "); }
cld exp_parser::parse(int prio) {
cld res;
while(next() == ' ') at++;
@ -247,4 +236,6 @@ string parser_help() {
return XLAT("Functions available: %1",
"(a)sin(h), (a)cos(h), (a)tan(h), exp, log, abs, re, im, conj, let(t=...,...t...), floor, frac, e, i, pi, s, ms, mousex, mousey, mousez");
}
logger hlog;
}