draw arcs

This commit is contained in:
Florian Stecker
2019-12-23 12:29:50 +01:00
parent c43e9d89e0
commit 0cde265d1e
6 changed files with 592 additions and 152 deletions

82
main.c
View File

@@ -18,24 +18,28 @@ DrawingContext *screen_context;
void setupContext(DrawingContext *ctx)
{
ctx->n_group_elements = NUM_GROUP_ELEMENTS;
ctx->p[0] = 5;
ctx->p[1] = 5;
ctx->p[2] = 5;
ctx->k[0] = 2;
ctx->k[1] = 2;
ctx->k[2] = 2;
ctx->parameter = 3.0;
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->parameter = 0.1;
ctx->show_boxes = 0;
ctx->show_boxes2 = 0;
ctx->show_attractors = 0;
ctx->show_reflectors = 0;
ctx->show_rotated_reflectors = 0;
ctx->show_limit= 1;
ctx->show_dual_limit= 0;
ctx->show_text = 1;
ctx->use_rotation_basis = 0;
ctx->limit_with_lines = 1;
ctx->use_repelling = 0;
ctx->limit_curve = malloc(3*ctx->n_group_elements*sizeof(double));
ctx->limit_curve_valid = 0;
ctx->limit_curve_count = -1;
ctx->group = malloc(ctx->n_group_elements*sizeof(groupelement_t));
generate_triangle_group(ctx->group, ctx->n_group_elements, ctx->p[0], ctx->p[1], ctx->p[2]);
@@ -132,13 +136,19 @@ void updateMatrices(DrawingContext *ctx)
gsl_matrix *tmp = getTempMatrix(ctx->ws);
if(ctx->use_rotation_basis % 3 == 0) {
if(ctx->use_rotation_basis % 4 == 0) {
gsl_matrix_memcpy(ctx->cob, ctx->cartan); // is this a good choice of basis for any reason?
} else if(ctx->use_rotation_basis % 3 == 1) {
computeRotationMatrix(ctx, tmp, "ac");
// gsl_matrix_set_identity(ctx->cob); // is this a good choice of basis for any reason?
} else if(ctx->use_rotation_basis % 4 == 1) {
computeRotationMatrix(ctx, tmp, "ba");
invert(tmp, ctx->cob, ctx->ws);
} else if(ctx->use_rotation_basis % 4 == 2) {
computeBoxTransform(ctx, "bca", "abc", ctx->cob);
// computeBoxTransform(ctx, "cab", "bca", ctx->cob);
// computeBoxTransform(ctx, "acb", "cba", ctx->cob);
} else {
computeBoxTransform(ctx, "abc", "cab", ctx->cob);
cartanMatrix(tmp, M_PI/ctx->p[0], M_PI/ctx->p[1], M_PI/ctx->p[2], 1.0);
diagonalize_symmetric_form(tmp, ctx->cob, ctx->ws);
}
releaseTempMatrices(ctx->ws, 1);
@@ -178,6 +188,7 @@ int processEvent(GraphicsInfo *info, XEvent *ev)
{
int state;
unsigned long key;
char filename[100];
switch(ev->type) {
@@ -198,12 +209,12 @@ int processEvent(GraphicsInfo *info, XEvent *ev)
computeLimitCurve(screen_context);
break;
case XK_Left:
screen_context->parameter /= exp(0.0001);
screen_context->parameter /= exp(0.00002);
updateMatrices(screen_context);
computeLimitCurve(screen_context);
break;
case XK_Right:
screen_context->parameter *= exp(0.0001);
screen_context->parameter *= exp(0.00002);
updateMatrices(screen_context);
computeLimitCurve(screen_context);
break;
@@ -218,12 +229,13 @@ int processEvent(GraphicsInfo *info, XEvent *ev)
computeLimitCurve(screen_context);
break;
case ' ':
screen_context->parameter = 2.890053638;
screen_context->parameter = 5.57959706;
updateMatrices(screen_context);
computeLimitCurve(screen_context);
break;
case XK_Return:
screen_context->parameter = 2.76375163;
// screen_context->parameter = 2.76375163;
screen_context->parameter = 5.29063366;
updateMatrices(screen_context);
computeLimitCurve(screen_context);
break;
@@ -247,12 +259,18 @@ int processEvent(GraphicsInfo *info, XEvent *ev)
case 'r':
TOGGLE(screen_context->show_reflectors);
break;
case 'x':
TOGGLE(screen_context->show_rotated_reflectors);
break;
case 'L':
TOGGLE(screen_context->limit_with_lines);
break;
case 'l':
TOGGLE(screen_context->show_limit);
break;
case 'd':
TOGGLE(screen_context->show_dual_limit);
break;
case 'R':
screen_context->use_rotation_basis++;
updateMatrices(screen_context);
@@ -260,10 +278,26 @@ int processEvent(GraphicsInfo *info, XEvent *ev)
break;
case 'p':
print(screen_context);
/*
screen_context->limit_with_lines = 0;
for(int i = 0; i <= 800; i++) {
screen_context->parameter = exp(0.005*i-2);
updateMatrices(screen_context);
computeLimitCurve(screen_context);
draw(screen_context);
sprintf(filename, "test%03d.png", i);
cairo_surface_write_to_png(info->buffer_surface, filename);
printf("Finished drawing %s\n", filename);
}
*/
break;
case 'f':
TOGGLE(screen_context->use_repelling);
computeLimitCurve(screen_context);
break;
case 't':
TOGGLE(screen_context->show_text);
break;
}
return STATUS_REDRAW;
@@ -286,20 +320,20 @@ int main()
return 1;
/*
info->dim->matrix.xx = 837.930824;
info->dim->matrix.xy = -712.651341;
info->dim->matrix.x0 = 180.427716;
info->dim->matrix.yx = 712.651341;
info->dim->matrix.yy = 837.930824;
info->dim->matrix.y0 = 1412.553240;
*/
info->dim->matrix.xx = 112.465171;
info->dim->matrix.xy = 0.000000;
info->dim->matrix.x0 = 891.180490;
info->dim->matrix.yx = 0.000000;
info->dim->matrix.yy = 112.465171;
info->dim->matrix.y0 = 506.676280;
*/
info->dim->matrix.xx = 274.573171;
info->dim->matrix.xy = 0.000000;
info->dim->matrix.x0 = 583.073462;
info->dim->matrix.yx = 0.000000;
info->dim->matrix.yy = 274.573171;
info->dim->matrix.y0 = 777.225293;
updateDimensions(info->dim);