start drawing rotation orbits
This commit is contained in:
85
main.c
85
main.c
@@ -60,7 +60,6 @@ void destroyContext(DrawingContext *ctx)
|
||||
void computeRotationMatrix(DrawingContext *ctx, gsl_matrix *result, const char *type)
|
||||
{
|
||||
gsl_matrix *tmp = getTempMatrix(ctx->ws);
|
||||
gsl_matrix *rot_basis = getTempMatrix(ctx->ws);
|
||||
gsl_matrix **gen = getTempMatrices(ctx->ws, 3);
|
||||
|
||||
ERROR(strlen(type) != 2, "Invalid call of computeRotationMatrix()\n");
|
||||
@@ -68,24 +67,61 @@ void computeRotationMatrix(DrawingContext *ctx, gsl_matrix *result, const char *
|
||||
initializeTriangleGenerators(gen, ctx->cartan);
|
||||
gsl_matrix_set_identity(tmp);
|
||||
multiply_right(tmp, gen[type[0]-'a'], ctx->ws);
|
||||
multiply_right(tmp, gen[type[1]-'b'], ctx->ws);
|
||||
multiply_right(tmp, gen[type[1]-'a'], 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");
|
||||
rotation_frame(tmp, result, ctx->ws);
|
||||
|
||||
releaseTempMatrices(ctx->ws, 4);
|
||||
}
|
||||
|
||||
void computeBoxTransform(DrawingContext *ctx, char *word1, char *word2, gsl_matrix *result)
|
||||
{
|
||||
vector_t p[2][3],i[2];
|
||||
vector_t std[4] = {
|
||||
{-1, -1, 1},
|
||||
{-1, 1, 1},
|
||||
{1, 1, 1},
|
||||
{1, -1, 1}
|
||||
};
|
||||
|
||||
gsl_vector **vertices = getTempVectors(ctx->ws, 4);
|
||||
gsl_vector **std_vertices = getTempVectors(ctx->ws, 4);
|
||||
gsl_matrix *tmp = getTempMatrix(ctx->ws);
|
||||
gsl_matrix *to_frame = getTempMatrix(ctx->ws);
|
||||
gsl_matrix *to_std_frame = getTempMatrix(ctx->ws);
|
||||
|
||||
fixedPoints(ctx, word1, p[0]);
|
||||
fixedPoints(ctx, word2, p[1]);
|
||||
|
||||
// intersect attracting line with neutral line of the other element
|
||||
for(int j = 0; j < 2; j++)
|
||||
i[j] = cross(cross(p[j%2][0],p[j%2][1]),cross(p[(j+1)%2][0],p[(j+1)%2][2]));
|
||||
|
||||
// box consists of p[0][0], i[0], p[1][0], i[1]
|
||||
|
||||
for(int i = 0; i < 4; i++)
|
||||
vectorToGsl(std[i], std_vertices[i]);
|
||||
|
||||
vectorToGsl(p[0][0], vertices[0]);
|
||||
vectorToGsl(i[0], vertices[1]);
|
||||
vectorToGsl(p[1][0], vertices[2]);
|
||||
vectorToGsl(i[1], vertices[3]);
|
||||
|
||||
projective_frame(std_vertices, to_std_frame, ctx->ws);
|
||||
projective_frame(vertices, to_frame, ctx->ws);
|
||||
invert(to_frame, tmp, ctx->ws);
|
||||
multiply(to_std_frame, tmp, result);
|
||||
|
||||
/*
|
||||
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));
|
||||
}
|
||||
LOOP(j) {
|
||||
printf("%.4f ", gsl_matrix_get(result, i, j));
|
||||
}
|
||||
printf("\n");
|
||||
}*/
|
||||
|
||||
invert(tmp, result, ctx->ws);
|
||||
|
||||
releaseTempMatrices(ctx->ws, 5);
|
||||
releaseTempVectors(ctx->ws, 8);
|
||||
releaseTempMatrices(ctx->ws, 3);
|
||||
}
|
||||
|
||||
void updateMatrices(DrawingContext *ctx)
|
||||
@@ -94,10 +130,13 @@ void updateMatrices(DrawingContext *ctx)
|
||||
LOOP(i) angle[i] = M_PI*ctx->k[i]/ctx->p[i];
|
||||
cartanMatrix(ctx->cartan, angle[0], angle[1], angle[2], ctx->parameter);
|
||||
|
||||
if(ctx->use_rotation_basis)
|
||||
computeRotationMatrix(ctx, ctx->cob, "ac");
|
||||
else
|
||||
if(ctx->use_rotation_basis) {
|
||||
// computeRotationMatrix(ctx, ctx->cob, "ac"); // and don't forget to invert!
|
||||
computeBoxTransform(ctx, "abc", "cab", ctx->cob);
|
||||
} else {
|
||||
gsl_matrix_memcpy(ctx->cob, ctx->cartan); // is this a good choice of basis for any reason?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void print(DrawingContext *screen)
|
||||
@@ -241,12 +280,22 @@ int main()
|
||||
if(!info)
|
||||
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;
|
||||
|
||||
updateDimensions(info->dim);
|
||||
|
||||
screen_context->dim = info->dim;
|
||||
|
||||
Reference in New Issue
Block a user