Beispiel #1
0
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);
}
Beispiel #2
0
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;



}