just used the program a bit
This commit is contained in:
94
main.c
94
main.c
@@ -15,16 +15,19 @@
|
||||
DrawingContext *screen_context;
|
||||
|
||||
// setup everything except cairo and dim, which will be provided by the graphics system
|
||||
void setupContext(DrawingContext *ctx)
|
||||
void setupContext(DrawingContext *ctx, int argc, char *argv[])
|
||||
{
|
||||
ctx->n_group_elements = NUM_GROUP_ELEMENTS;
|
||||
ctx->p[0] = 9;
|
||||
ctx->p[1] = 9;
|
||||
ctx->p[2] = 9;
|
||||
ctx->k[0] = 4;
|
||||
ctx->k[1] = 4;
|
||||
ctx->k[2] = 4;
|
||||
ctx->parameter = 5.35;
|
||||
ctx->p[0] = atoi(argv[1]);
|
||||
ctx->p[1] = atoi(argv[2]);
|
||||
ctx->p[2] = atoi(argv[3]);
|
||||
ctx->k[0] = atoi(argv[4]);
|
||||
ctx->k[1] = atoi(argv[5]);
|
||||
ctx->k[2] = atoi(argv[6]);
|
||||
if(argc > 7)
|
||||
ctx->parameter = atof(argv[7]);
|
||||
else
|
||||
ctx->parameter = 1.0;
|
||||
// ctx->parameter = 2.77;
|
||||
// ctx->parameter = 0.1;
|
||||
ctx->show_boxes = 0;
|
||||
@@ -35,9 +38,14 @@ void setupContext(DrawingContext *ctx)
|
||||
ctx->show_limit= 1;
|
||||
ctx->show_dual_limit= 0;
|
||||
ctx->show_text = 1;
|
||||
ctx->mode = 0;
|
||||
ctx->use_rotation_basis = 0;
|
||||
ctx->limit_with_lines = 1;
|
||||
ctx->limit_with_lines = 0;
|
||||
ctx->use_repelling = 0;
|
||||
ctx->show_marking = 1;
|
||||
ctx->marking.x = -0.73679;
|
||||
ctx->marking.y = -0.01873;
|
||||
ctx->show_coxeter_orbit = 0;
|
||||
|
||||
ctx->limit_curve = malloc(3*ctx->n_group_elements*sizeof(double));
|
||||
ctx->limit_curve_count = -1;
|
||||
@@ -137,21 +145,7 @@ void updateMatrices(DrawingContext *ctx)
|
||||
|
||||
gsl_matrix *tmp = getTempMatrix(ctx->ws);
|
||||
|
||||
if(ctx->use_rotation_basis % 4 == 0) {
|
||||
gsl_matrix_memcpy(ctx->cob, ctx->cartan); // is this a good choice of basis for any reason?
|
||||
|
||||
gsl_matrix_set(tmp, 0, 0, 1.0);
|
||||
gsl_matrix_set(tmp, 0, 1, -1.0);
|
||||
gsl_matrix_set(tmp, 0, 2, 0.0);
|
||||
gsl_matrix_set(tmp, 1, 0, 1.0);
|
||||
gsl_matrix_set(tmp, 1, 1, 1.0);
|
||||
gsl_matrix_set(tmp, 1, 2, 1.0);
|
||||
gsl_matrix_set(tmp, 2, 0, 0.0);
|
||||
gsl_matrix_set(tmp, 2, 1, -1.0);
|
||||
gsl_matrix_set(tmp, 2, 2, 1.0);
|
||||
multiply_left(tmp, ctx->cob, ctx->ws);
|
||||
|
||||
/*
|
||||
if(ctx->use_rotation_basis % 5 == 0) {
|
||||
gsl_matrix_set(tmp, 0, 0, 0.0);
|
||||
gsl_matrix_set(tmp, 0, 1, sqrt(3.0)/2.0);
|
||||
gsl_matrix_set(tmp, 0, 2, -sqrt(3.0)/2.0);
|
||||
@@ -162,13 +156,12 @@ void updateMatrices(DrawingContext *ctx)
|
||||
gsl_matrix_set(tmp, 2, 1, 1.0);
|
||||
gsl_matrix_set(tmp, 2, 2, 1.0);
|
||||
gsl_matrix_memcpy(ctx->cob, tmp);
|
||||
*/
|
||||
|
||||
// gsl_matrix_set_identity(ctx->cob); // is this a good choice of basis for any reason?
|
||||
} else if(ctx->use_rotation_basis % 4 == 1) {
|
||||
} else if(ctx->use_rotation_basis % 5 == 1) {
|
||||
gsl_matrix_memcpy(ctx->cob, ctx->cartan); // is this a good choice of basis for any reason?
|
||||
} else if(ctx->use_rotation_basis % 5 == 2) {
|
||||
computeRotationMatrix(ctx, tmp, "ba");
|
||||
invert(tmp, ctx->cob, ctx->ws);
|
||||
} else if(ctx->use_rotation_basis % 4 == 2) {
|
||||
} else if(ctx->use_rotation_basis % 5 == 3) {
|
||||
computeBoxTransform(ctx, "bca", "abc", ctx->cob);
|
||||
// computeBoxTransform(ctx, "cab", "bca", ctx->cob);
|
||||
// computeBoxTransform(ctx, "acb", "cba", ctx->cob);
|
||||
@@ -180,6 +173,21 @@ void updateMatrices(DrawingContext *ctx)
|
||||
releaseTempMatrices(ctx->ws, 1);
|
||||
}
|
||||
|
||||
void output_info(DrawingContext *ctx)
|
||||
{
|
||||
vector_t p[4][3];
|
||||
point_t pt;
|
||||
|
||||
fixedPoints(ctx, "abc", p[0]);
|
||||
fixedPoints(ctx, "bca", p[1]);
|
||||
fixedPoints(ctx, "cab", p[2]);
|
||||
|
||||
pt = vectorToPoint(ctx, p[0][0]);
|
||||
printf("(abc)-+ = (%f %f)\n", pt.x, pt.y);
|
||||
pt = vectorToPoint(ctx, p[1][0]);
|
||||
printf("(bca)-+ = (%f %f)\n", pt.x, pt.y);
|
||||
}
|
||||
|
||||
void print(DrawingContext *screen)
|
||||
{
|
||||
DrawingContext file;
|
||||
@@ -216,7 +224,22 @@ int processEvent(GraphicsInfo *info, XEvent *ev)
|
||||
unsigned long key;
|
||||
char filename[100];
|
||||
|
||||
// fprintf(stderr, "Event: %d\n", ev->type);
|
||||
|
||||
switch(ev->type) {
|
||||
case ButtonPress:
|
||||
state = ev->xbutton.state & (ShiftMask | LockMask | ControlMask);
|
||||
|
||||
if(ev->xbutton.button == 1 && state & ShiftMask) {
|
||||
screen_context->marking.x = (double)ev->xbutton.x;
|
||||
screen_context->marking.y = (double)ev->xbutton.y;
|
||||
printf("mouse button pressed: %f, %f\n", screen_context->marking.x, screen_context->marking.y);
|
||||
cairo_set_matrix(screen_context->cairo, &screen_context->dim->matrix);
|
||||
cairo_device_to_user(screen_context->cairo, &screen_context->marking.x, &screen_context->marking.y);
|
||||
printf("mouse button pressed transformed: %f, %f\n", screen_context->marking.x, screen_context->marking.y);
|
||||
return STATUS_REDRAW;
|
||||
}
|
||||
break;
|
||||
|
||||
case KeyPress:
|
||||
state = ev->xkey.state & (ShiftMask | LockMask | ControlMask);
|
||||
@@ -273,6 +296,9 @@ int processEvent(GraphicsInfo *info, XEvent *ev)
|
||||
printf("matrix.yy = %f;\n", info->dim->matrix.yy);
|
||||
printf("matrix.y0 = %f;\n", info->dim->matrix.y0);
|
||||
break;
|
||||
case 'i':
|
||||
output_info(screen_context);
|
||||
break;
|
||||
case 'b':
|
||||
TOGGLE(screen_context->show_boxes);
|
||||
break;
|
||||
@@ -348,6 +374,12 @@ int processEvent(GraphicsInfo *info, XEvent *ev)
|
||||
case 't':
|
||||
TOGGLE(screen_context->show_text);
|
||||
break;
|
||||
case 'c':
|
||||
TOGGLE(screen_context->show_coxeter_orbit);
|
||||
break;
|
||||
case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0':
|
||||
screen_context->mode = key - '0';
|
||||
break;
|
||||
}
|
||||
|
||||
return STATUS_REDRAW;
|
||||
@@ -356,12 +388,12 @@ int processEvent(GraphicsInfo *info, XEvent *ev)
|
||||
return STATUS_NOTHING;
|
||||
}
|
||||
|
||||
int main()
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
GraphicsInfo *info;
|
||||
|
||||
screen_context = malloc(sizeof(DrawingContext));
|
||||
setupContext(screen_context);
|
||||
setupContext(screen_context, argc, argv);
|
||||
updateMatrices(screen_context);
|
||||
computeLimitCurve(screen_context);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user