void tree_node::draw_edges(mp_graphics &G, INT rad, INT f_circle, INT f_circletext, INT f_i, INT f_has_parent, INT parent_x, INT parent_y, INT max_depth, INT f_edge_labels, INT f_has_draw_vertex_callback, void (*draw_vertex_callback)(tree *T, mp_graphics *G, INT *v, INT layer, tree_node *N, INT x, INT y, INT dx, INT dy), tree *T ) { //INT rad = 20; //INT dx = rad; // / sqrt(2); //INT dy = dx; INT x, y, i; INT Px[3], Py[3]; #if DONT_DRAW_ROOT_NODE if (!f_has_parent) { x = placement_x; y = placement_y; for (i = 0; i < nb_children; i++) { children[i]->draw_edges(G, rad, f_circletext, f_i, TRUE, x, y, max_depth, f_edge_labels, f_has_draw_vertex_callback, draw_vertex_callback, T); } return; } #endif x = placement_x; y = placement_y; // calc_y_coordinate(y, depth, max_depth); cout << "{" << x << "," << y << "}, // depth " << depth << " "; print_path(); cout << endl; Px[1] = x; Py[1] = y; if (f_has_parent #if DONT_DRAW_ROOT_NODE && depth >= 2 #endif ) { Px[0] = parent_x; Py[0] = parent_y; G.polygon2(Px, Py, 0, 1); if (f_edge_labels && char_data) { Px[2] = (x + parent_x) >> 1; Py[2] = (y + parent_y) >> 1; G.aligned_text(Px[2], Py[2], "" /*"tl"*/, char_data); }
void draw_points(mp_graphics &G, projective_space *P, INT *pts, INT nb_points, INT verbose_level) { INT f_v = (verbose_level >= 1); INT x, y, Q, a, b; //, c, d; INT *Px, *Py; INT u; INT q; INT v[3]; INT x1, x2, x3; //INT y1, y2, y3; INT rad = 20; INT i; //, j; if (f_v) { cout << "draw_points" << endl; } q = P->q; u = 500 / q; if (q == 4) { u = 400 / q; } Q = 2 * (q + 3) + 1; if (f_v) { cout << "u=" << u << endl; cout << "Q=" << Q << endl; } Px = NEW_INT(Q * Q); Py = NEW_INT(Q * Q); for (x = 0; x < Q; x++) { for (y = 0; y < Q; y++) { Px[x * Q + y] = x * u; Py[x * Q + y] = y * u; } } if (f_v) { cout << "drawing points" << endl; } for (i = 0; i < nb_points; i++) { P->unrank_point(v, pts[i]); cout << "point " << i << " : "; INT_vec_print(cout, v, 3); cout << endl; x1 = v[0]; x2 = v[1]; x3 = v[2]; get_ab(q, x1, x2, x3, a, b); G.nice_circle(Px[a * Q + b], Py[a * Q + b], rad); } FREE_INT(Px); FREE_INT(Py); }
void draw_grid_(mp_graphics &G, INT xmax, INT ymax, INT q, INT type, INT param_a) { grid_frame F; INT i, j; INT Px[10], Py[10]; BYTE text[1000]; INT rad = 10000; F.f_matrix_notation = FALSE; F.m = q - 1; F.n = q - 1; F.origin_x = 0.; F.origin_y = 0.; F.dx = ONE_MILLION / F.m; // goes down in matrix notation F.dy = ONE_MILLION / F.n; // goes accross cout << "math_day::draw_tree2" << endl; cout << "dx=" << F.dx << endl; cout << "dy=" << F.dy << endl; //INT line_dashing = 5; //G.sl_udsty(line_dashing); // draw horizontal lines for (i = 0; i <= q - 1; i++) { Px[0] = (INT)(F.origin_x + F.m * F.dx); Py[0] = (INT)(F.origin_y + i * F.dy); Px[1] = (INT)(F.origin_x + 0 * F.dx); Py[1] = Py[0]; Px[2] = (INT)(F.origin_x + (-1) * F.dx); Py[2] = (INT)(F.origin_y + i * F.dy); G.polygon2(Px, Py, 0, 1); sprintf(text, "%ld", i); G.aligned_text(Px[2], Py[2], "", text); } // draw vertical lines for (i = 0; i <= q - 1; i++) { Px[0] = (INT)(F.origin_x + i * F.dx); Py[0] = (INT)(F.origin_y); Px[1] = Px[0]; Py[1] = (INT)(F.origin_y + (F.n) * F.dy); Px[2] = (INT)(F.origin_x + i * F.dx); Py[2] = (INT)(F.origin_y + (-1) * F.dy); G.polygon2(Px, Py, 0, 1); sprintf(text, "%ld", i); G.aligned_text(Px[2], Py[2], "", text); } //sprintf(text, "{\\bf \\Large %s}", time[i]); //G.aligned_text(Px, Py, 0, "", text); finite_field *Fq; Fq = new finite_field; Fq->init(q, 0); for (i = 0; i < q; i++) { if (type == -1) { continue; } else if (type == 0) { if (param_a == -1) { j = Fq->alpha_power(i); } else { j = Fq->power(param_a, i); } } else if (type == 1) { if (param_a == -1) { j = Fq->mult(3, i); } else { j = Fq->mult(param_a, i); } } else if (type == 2) { if (i == 0) continue; j = Fq->inverse(i); } Px[0] = (INT)(F.origin_x + i * F.dx); Py[0] = (INT)(F.origin_y + j * F.dy); G.nice_circle(Px[0], Py[0], rad); } delete Fq; }
void draw_action_(mp_graphics &G, INT *Adjacency, INT m, INT n, INT f_cartesian) { INT PX[100], PY[100]; double delta_phi1; double delta_phi2; double phi0, phi1, d_phi, phi_t, phi_tp1; double r0, r1, r0a, r1a, dr, r_t, r_tp1; double x1, y1, x2, y2; double offset; INT step; INT i, j, t; INT rad; BYTE str[1000]; if (f_cartesian) { delta_phi1 = 2000 / m; delta_phi2 = 2000 / n; step = 1; offset = 70.; rad = 15; } else { delta_phi1 = (2. * M_PI) / m; delta_phi2 = (2. * M_PI) / n; step = 25; offset = 30.; rad = 5; } r0 = 400; r1 = 1200; r0a = r0 - offset; r1a = r1 + offset; dr = (r1 - r0) / step; for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { if (Adjacency[i * n+ j] == 0) continue; phi0 = i * delta_phi1; phi1 = j * delta_phi2; d_phi = (phi1 - phi0) / step; r_t = r0; phi_t = phi0; for (t = 0; t < step; t++) { phi_tp1 = phi_t + d_phi; r_tp1 = r_t + dr; if (f_cartesian) { x1 = phi_t; y1 = r_t; x2 = phi_tp1; y2 = r_tp1; } else { x1 = cos(phi_t) * r_t; y1 = sin(phi_t) * r_t; x2 = cos(phi_tp1) * r_tp1; y2 = sin(phi_tp1) * r_tp1; } PX[0] = (INT)x1; PY[0] = (INT)y1; PX[1] = (INT)x2; PY[1] = (INT)y2; G.polygon2(PX, PY, 0, 1); r_t = r_tp1; phi_t = phi_tp1; } } } for (i = 0; i < m; i++) { phi0 = i * delta_phi1; if (f_cartesian) { x1 = phi0; y1 = r0; } else { x1 = cos(phi0) * r0; y1 = sin(phi0) * r0; } PX[0] = (INT)x1; PY[0] = (INT)y1; G.sf_interior(100); G.sf_color(0); G.circle(PX[0], PY[0], rad); G.sf_interior(0); G.sf_color(0); G.circle(PX[0], PY[0], rad); phi0 = i * delta_phi1; if (f_cartesian) { x1 = phi0; y1 = r0a; } else { x1 = cos(phi0) * r0a; y1 = sin(phi0) * r0a; } PX[0] = (INT)x1; PY[0] = (INT)y1; sprintf(str, "$x_{%ld}$", (INT) i + 1); G.aligned_text(PX[0], PY[0], "", str); } for (i = 0; i < n; i++) { phi1 = i * delta_phi2; if (f_cartesian) { x1 = phi1; y1 = r1; } else { x1 = cos(phi1) * r1; y1 = sin(phi1) * r1; } PX[0] = (INT)x1; PY[0] = (INT)y1; G.sf_interior(100); G.sf_color(0); G.circle(PX[0], PY[0], rad); G.sf_interior(0); G.sf_color(0); G.circle(PX[0], PY[0], rad); phi1 = i * delta_phi2; if (f_cartesian) { x1 = phi1; y1 = r1a; } else { x1 = cos(phi1) * r1a; y1 = sin(phi1) * r1a; } PX[0] = (INT)x1; PY[0] = (INT)y1; sprintf(str, "$y_{%ld}$", (INT) i + 1); G.aligned_text(PX[0], PY[0], "", str); } }
void draw_grid_(mp_graphics &G, INT q, INT f_include_line_at_infinity, INT verbose_level) { INT f_v = (verbose_level >= 1); INT x, y, Q, a, b, c, d; INT *Px, *Py; INT u; //INT x1, x2, x3; //INT y1, y2, y3; //INT rad = 20; //INT i, j; if (f_v) { cout << "draw_grid_" << endl; } u = 500 / q; if (q == 4) { u = 400 / q; } Q = 2 * (q + 3) + 1; if (f_v) { cout << "u=" << u << endl; cout << "Q=" << Q << endl; } Px = NEW_INT(Q * Q); Py = NEW_INT(Q * Q); for (x = 0; x < Q; x++) { for (y = 0; y < Q; y++) { Px[x * Q + y] = x * u; Py[x * Q + y] = y * u; } } if (f_v) { cout << "drawing grid" << endl; } //G.polygon2(Px, Py, qq, n - 1); for (x = 0; x < q; x++) { a = Xcoord(x); b = Ycoord(0); c = Xcoord(x); d = Ycoord(q - 1); cout << a << "," << b << "," << c << "," << d << endl; G.polygon2(Px, Py, a * Q + b, c * Q + d); } for (y = 0; y < q; y++) { a = Xcoord(0); b = Ycoord(y); c = Xcoord(q - 1); d = Ycoord(y); cout << a << "," << b << "," << c << "," << d << endl; G.polygon2(Px, Py, a * Q + b, c * Q + d); } if (f_include_line_at_infinity) { if (f_v) { cout << "drawing line at infinity" << endl; } a = Xcoord(0); b = Ycoord(q); c = Xcoord(q); d = Ycoord(q); cout << a << "," << b << "," << c << "," << d << endl; G.polygon2(Px, Py, a * Q + b, c * Q + d); } if (f_v) { cout << "drawing text" << endl; } for (x = 0; x < q; x++) { BYTE str[1000]; sprintf(str, "$%ld$", x); a = Xcoord(x); b = Ycoord(-1); G.aligned_text(Px[a * Q + b], Py[a * Q + b], "t", str); } for (y = 0; y < q; y++) { BYTE str[1000]; sprintf(str, "$%ld$", y); a = Xcoord(-1); b = Ycoord(y); G.aligned_text(Px[a * Q + b], Py[a * Q + b], "r", str); } if (f_include_line_at_infinity) { BYTE str[1000]; sprintf(str, "$\\infty$"); a = Xcoord(-1); b = Ycoord(q); G.aligned_text(Px[a * Q + b], Py[a * Q + b], "r", str); } //done: FREE_INT(Px); FREE_INT(Py); }