transform into rotation basis

This commit is contained in:
Florian Stecker
2019-02-11 15:20:56 +01:00
parent 8146f0ee60
commit 91bd66f057
3 changed files with 77 additions and 18 deletions

37
main.c
View File

@@ -30,6 +30,7 @@ void setupContext(DrawingContext *ctx)
ctx->show_attractors = 0;
ctx->show_reflectors = 0;
ctx->show_limit= 1;
ctx->use_rotation_basis = 0;
ctx->limit_with_lines = 1;
ctx->use_repelling = 0;
@@ -61,7 +62,36 @@ void updateMatrices(DrawingContext *ctx)
double angle[3];
LOOP(i) angle[i] = M_PI*ctx->k[i]/ctx->p[i];
cartanMatrix(ctx->cartan, angle[0], angle[1], angle[2], ctx->parameter);
gsl_matrix_memcpy(ctx->cob, ctx->cartan); // is this a good choice of basis
if(!ctx->use_rotation_basis)
gsl_matrix_memcpy(ctx->cob, ctx->cartan); // is this a good choice of basis
else {
gsl_matrix *tmp = getTempMatrix(ctx->ws);
gsl_matrix *rot_basis = getTempMatrix(ctx->ws);
gsl_matrix **gen = getTempMatrices(ctx->ws, 3);
initializeTriangleGenerators(gen, ctx->cartan);
gsl_matrix_set_identity(tmp);
multiply_right(tmp, gen[0], ctx->ws);
multiply_right(tmp, gen[2], ctx->ws);
gsl_eigen_nonsymmv_params(0, ctx->ws->work_nonsymmv);
int r = gsl_eigen_nonsymmv(tmp, ctx->ws->eval_complex, ctx->ws->evec_complex, ctx->ws->work_nonsymmv);
ERROR(r, "gsl_eigen_nonsymmv failed!\n");
LOOP(i) {
gsl_complex x = gsl_matrix_complex_get(ctx->ws->evec_complex, i, 0);
gsl_complex y = gsl_matrix_complex_get(ctx->ws->evec_complex, i, 1);
gsl_complex z = gsl_matrix_complex_get(ctx->ws->evec_complex, i, 2);
gsl_matrix_set(tmp, i, 0, GSL_REAL(x)+GSL_REAL(y));
gsl_matrix_set(tmp, i, 1, GSL_IMAG(x)-GSL_IMAG(y));
gsl_matrix_set(tmp, i, 2, GSL_REAL(z));
}
invert(tmp, ctx->cob, ctx->ws);
releaseTempMatrices(ctx->ws, 5);
}
}
void print(DrawingContext *screen)
@@ -173,6 +203,11 @@ int processEvent(GraphicsInfo *info, XEvent *ev)
case 'l':
TOGGLE(screen_context->show_limit);
break;
case 'R':
TOGGLE(screen_context->use_rotation_basis);
updateMatrices(screen_context);
computeLimitCurve(screen_context);
break;
case 'p':
print(screen_context);
break;