draw new boxes (J)

This commit is contained in:
Florian Stecker 2020-06-29 18:59:49 -05:00
parent bc2fdcd132
commit 17de77de59
2 changed files with 118 additions and 239 deletions

356
draw.c
View File

@ -551,220 +551,148 @@ void drawBoxes(DrawingContext *ctx)
cairo_save(C); cairo_save(C);
vector_t p[22][3]; vector_t p[22][3];
vector_t l[6][3]; vector_t l[22][3];
vector_t alpha[6]; vector_t alpha[6];
fixedPoints(ctx, "abc", p[0]); fixedPoints(ctx, "abc", p[0]);
fixedPoints(ctx, "bca", p[1]); fixedPoints(ctx, "bca", p[1]);
fixedPoints(ctx, "cab", p[2]); fixedPoints(ctx, "cab", p[2]);
fixedPoints(ctx, "abc", p[3]);
fixedPoints(ctx, "ab abc ba", p[4]);
fixedPoints(ctx, "abab abc baba", p[5]);
fixedPoints(ctx, "ababab abc bababa", p[6]);
fixedPoints(ctx, "abababab abc babababa", p[7]);
fixedPoints(ctx, "babababa abc abababab", p[8]);
fixedPoints(ctx, "bababa abc ababab", p[9]);
fixedPoints(ctx, "baba abc abab", p[10]);
fixedPoints(ctx, "ba abc ab", p[11]);
fixedPoints(ctx, "bca", p[12]);
fixedPoints(ctx, "b abc b", p[13]);
fixedPoints(ctx, "bab abc bab", p[14]);
fixedPoints(ctx, "babab abc babab", p[15]);
fixedPoints(ctx, "bababab abc bababab", p[16]);
fixedPoints(ctx, "abababab bca babababa", p[17]);
fixedPoints(ctx, "ababab bca bababa", p[18]);
fixedPoints(ctx, "abab bca baba", p[19]);
fixedPoints(ctx, "ab bca ba", p[20]);
initializeTriangleGenerators(gen, ctx->cartan); initializeTriangleGenerators(gen, ctx->cartan);
for(int i = 0; i < 6; i++) LOOP(j) l[i][j] = cross(p[i][(3-j)%3], p[i][(4-j)%3]); for(int i = 0; i < 22; i++) LOOP(j) l[i][j] = cross(p[i][(3-j)%3], p[i][(4-j)%3]);
LOOP(i) LOOP(j) alpha[i].x[j] = gsl_matrix_get(ctx->cartan, i, j); // LOOP(i) LOOP(j) alpha[i].x[j] = gsl_matrix_get(ctx->cartan, i, j);
cairo_set_source_rgb(C, 1.0, 0, 0);
// drawCurvedBox(ctx, 'A', "");
/*
fixedPoints(ctx, "b abc b", p[3]);
fixedPoints(ctx, "ab abc ba", p[4]);
fixedPoints(ctx, "ab a cab a ba", p[5]);
fixedPoints(ctx, "ab ca cab ac ba", p[6]);
fixedPoints(ctx, "abab abc baba", p[7]);
fixedPoints(ctx, "abab a cab a baba", p[8]);
fixedPoints(ctx, "abab ca cab ac baba", p[9]);
fixedPoints(ctx, "ababab abc bababa", p[10]);
fixedPoints(ctx, "ababab a cab a bababa", p[11]);
fixedPoints(ctx, "ababab ca cab ac bababa", p[12]);
fixedPoints(ctx, "abababab abc babababa", p[13]);
fixedPoints(ctx, "abababab a cab a babababa", p[14]);
fixedPoints(ctx, "abababab ca cab ac babababa", p[15]);
fixedPoints(ctx, "ababababab abc bababababa", p[16]);
fixedPoints(ctx, "ababababab a cab a bababababa", p[17]);
fixedPoints(ctx, "ababababab ca cab ac bababababa", p[18]);
fixedPoints(ctx, "abababababab abc babababababa", p[19]);
fixedPoints(ctx, "abababababab a cab a babababababa", p[20]);
fixedPoints(ctx, "abababababab ca cab ac babababababa", p[21]);
cairo_set_source_rgb(C, 0.5, 0.5, 0.5);
drawArc(ctx, "ab", p[0][0], VT_POINT, cross(p[1][0], p[1][1]), VT_LINE, p[3][0], 1);
drawArc(ctx, "ab", p[1][0], VT_POINT, cross(p[0][0], p[0][1]), VT_LINE, p[4][0], 1);
drawCovector(ctx, l[0][0]);
drawCovector(ctx, l[1][0]);
cairo_set_source_rgb(C, 1.0, 0, 0);
drawArc(ctx, "abcaba", p[0][0], VT_POINT, cross(p[4][0],p[4][1]), VT_LINE, p[5][0], 1);
drawArc(ctx, "abcaba", p[4][0], VT_POINT, cross(p[0][0],p[0][1]), VT_LINE, p[6][0], 1);
drawArc(ctx, "ababcababa", p[4][0], VT_POINT, cross(p[7][0],p[7][1]), VT_LINE, p[8][0], 1);
drawArc(ctx, "ababcababa", p[7][0], VT_POINT, cross(p[4][0],p[4][1]), VT_LINE, p[9][0], 1);
drawArc(ctx, "abababcabababa", p[7 ][0], VT_POINT, cross(p[10][0],p[10][1]), VT_LINE, p[11][0], 1);
drawArc(ctx, "abababcabababa", p[10][0], VT_POINT, cross(p[7 ][0],p[7 ][1]), VT_LINE, p[12][0], 1);
drawArc(ctx, "ababababcababababa", p[10][0], VT_POINT, cross(p[13][0],p[13][1]), VT_LINE, p[14][0], 1);
drawArc(ctx, "ababababcababababa", p[13][0], VT_POINT, cross(p[10][0],p[10][1]), VT_LINE, p[15][0], 1);
drawArc(ctx, "abababababcabababababa", p[13][0], VT_POINT, cross(p[16][0],p[16][1]), VT_LINE, p[17][0], 1);
drawArc(ctx, "abababababcabababababa", p[16][0], VT_POINT, cross(p[13][0],p[13][1]), VT_LINE, p[18][0], 1);
drawArc(ctx, "ababababababcababababababa", p[16][0], VT_POINT, cross(p[19][0],p[19][1]), VT_LINE, p[20][0], 1);
drawArc(ctx, "ababababababcababababababa", p[19][0], VT_POINT, cross(p[16][0],p[16][1]), VT_LINE, p[21][0], 1);
// drawCovector(ctx, cross(p[4][0],p[4][1]));
// drawCovector(ctx, cross(p[7][0],p[7][1]));
// drawCovector(ctx, cross(p[10][0],p[10][1]));
// drawCovector(ctx, cross(p[13][0],p[13][1]));
// drawCovector(ctx, cross(p[16][0],p[16][1]));
// drawCovector(ctx, cross(p[19][0],p[19][1]));
*/
cairo_set_source_rgb(C, 0, 0, 1.0);
cairo_set_line_width(C, 1.5/ctx->dim->scalefactor);
drawCurvedBox(ctx, 'C', "ab");
drawCurvedBox(ctx, 'C', "abab");
drawCurvedBox(ctx, 'C', "ababab");
drawCurvedBox(ctx, 'C', "abababab");
// drawCurvedBox(ctx, 'C', "babababa");
// drawCurvedBox(ctx, 'C', "bababa");
cairo_set_source_rgb(C, 1.0, 0, 0);
// drawCurvedBox(ctx, 'C', "b");
// drawCurvedBox(ctx, 'C', "bab");
// drawCurvedBox(ctx, 'C', "babab");
// drawCurvedBox(ctx, 'C', "bababab");
// drawCurvedBox(ctx, 'C', "ba");
// drawCurvedBox(ctx, 'C', "");
/*
cairo_set_source_rgb(C, 1.0, 0, 0);
fixedPoints(ctx, "ababa abc ababa", p[3]);
drawCovector(ctx, cross(p[3][0],p[3][1]));
fixedPoints(ctx, "abababa abc abababa", p[3]);
drawCovector(ctx, cross(p[3][0],p[3][1]));
fixedPoints(ctx, "ababababa abc ababababa", p[3]);
drawCovector(ctx, cross(p[3][0],p[3][1]));
fixedPoints(ctx, "bababab abc bababab", p[3]);
drawCovector(ctx, cross(p[3][0],p[3][1]));
fixedPoints(ctx, "babab abc babab", p[3]);
drawCovector(ctx, cross(p[3][0],p[3][1]));
fixedPoints(ctx, "bab abc bab", p[3]);
drawCovector(ctx, cross(p[3][0],p[3][1]));
fixedPoints(ctx, "b abc b", p[3]);
drawCovector(ctx, cross(p[3][0],p[3][1]));
fixedPoints(ctx, "a abc a", p[3]);
drawCovector(ctx, cross(p[3][0],p[3][1]));
fixedPoints(ctx, "aba abc aba", p[3]);
drawCovector(ctx, cross(p[3][0],p[3][1]));
*/
// drawCovector(ctx, cross(p[7][0],p[7][1]));
// drawCovector(ctx, cross(p[10][0],p[10][1]));
// drawCovector(ctx, cross(p[13][0],p[13][1]));
// drawCovector(ctx, cross(p[16][0],p[16][1]));
// drawCovector(ctx, cross(p[19][0],p[19][1]));
cairo_set_line_width(C, 2.0/ctx->dim->scalefactor); cairo_set_line_width(C, 2.0/ctx->dim->scalefactor);
cairo_set_source_rgb(C, 0, 0, 0); cairo_set_source_rgb(C, 0, 0, 0);
drawCurvedBox(ctx, 'A', ""); drawRotationOrbit(ctx, "ab", p[0][0]);
// drawRotationOrbit(ctx, "ab", p[1][0]); // drawRotationOrbit(ctx, "bc", p[0][0]);
cairo_set_source_rgb(C, 1.0, 0, 0); cairo_set_source_rgb(C, 0.5, 0.5, 1);
// drawCurvedBox(ctx, 'B', "abca"); // drawRotationOrbit(ctx, "ca", p[0][0]);
// drawCurvedBox(ctx, 'A', "abcabc");
// drawRotationOrbit(ctx, "ab", p[1][0]);
// drawCurvedBox(ctx, 'C', "");
// drawCurvedBox(ctx, 'C', "b"); for(int i = 0; i < 18; i++) {
// drawCurvedBox(ctx, 'C', "bab"); if(i == 0)
// drawCurvedBox(ctx, 'C', "babab"); cairo_set_source_rgb(C, 1, 0, 0);
// drawCurvedBox(ctx, 'C', "bababab"); else if(i == 8 || i == 10)
cairo_set_source_rgb(C, 0, 0, 1);
// drawCurvedBox(ctx, 'C', "ababababab"); else if(i == 9)
// drawCurvedBox(ctx, 'C', "abababababab"); cairo_set_source_rgb(C, 0, 0.6, 0);
// drawCurvedBox(ctx, 'C', "ababababababab"); else
// drawCurvedBox(ctx, 'C', "abababababababab"); cairo_set_source_rgb(C, 0, 0, 0);
drawVector(ctx, p[3+i][0]);
drawCovector(ctx, l[3+i][0]);
/* }
drawRotationOrbit(ctx, "ca", p[0][0]);
drawRotationOrbit(ctx, "ab", p[1][0]);
drawRotationOrbit(ctx, "bc", p[2][0]);
drawRotationOrbit(ctx, "cbac", p[4][0]);
drawRotationOrbit(ctx, "abca", p[5][0]);
*/
/*
cairo_set_source_rgb(C, 0.0, 0.0, 1.0);
drawDualRotationOrbit(ctx, "ca", l[0][2]);
drawDualRotationOrbit(ctx, "ab", l[1][2]);
drawDualRotationOrbit(ctx, "bc", l[2][2]);
drawDualRotationOrbit(ctx, "bacb", l[3][2]);
drawDualRotationOrbit(ctx, "cbac", l[4][2]);
drawDualRotationOrbit(ctx, "abca", l[5][2]);
*/
/*
cairo_set_source_rgb(C, 0, 0, 1);
fixedPoints(ctx, "abc", p[0]); //
fixedPoints(ctx, "ababcba", p[1]);
drawRotationOrbit(ctx, "abcaba", p[0][0]); // abcaba a rar- r-ar a rar- a
drawRotationOrbit(ctx, "ab", p[0][0]); // ab a rar- a rar- rar- a
drawRotationOrbit(ctx, "abcabcba", p[0][0]); // abc abc ba
drawCovector(ctx, cross(p[0][0],p[0][1]));
drawCovector(ctx, cross(p[1][0],p[1][1]));
cairo_set_source_rgb(C, 0, 0.7, 0);
fixedPoints(ctx, "ab abc ba", p[0]); //
fixedPoints(ctx, "ab ababcba ba", p[1]);
drawRotationOrbit(ctx, "ababcababa", p[0][0]); // abcaba a rar- r-ar a rar- a
drawRotationOrbit(ctx, "ab", p[0][0]); // ab a rar- a rar- rar- a
drawRotationOrbit(ctx, "ababcabcbaba", p[0][0]); // abc abc ba
drawCovector(ctx, cross(p[0][0],p[0][1]));
drawCovector(ctx, cross(p[1][0],p[1][1]));
*/
cairo_set_source_rgb(C, 0, 0, 1.0); cairo_set_source_rgb(C, 0, 0, 1.0);
// drawRotationOrbit(ctx, "bcab", p[3][0]);
// drawRotationOrbit(ctx, "abca", p[5][0]);
// drawRotationOrbit(ctx, "bacb", p[3][0]);
// LOOP(i) drawVector(ctx, p[i+3][0]); // drawRotationOrbit(ctx, "ab", cross(l[0][0], l[2][1]));
// drawRotationOrbit(ctx, "abca", p[0][0]);
cairo_set_source_rgb(C, 0.5, 0.5, 0.5);
// drawCovector(ctx, alpha[1]);
// drawCovector(ctx, alpha[2]);
/*
alpha[3] = apply_transpose(gen[1], alpha[0]);
drawCovector(ctx, alpha[3]);
*/
cairo_restore(C); cairo_restore(C);
releaseTempMatrices(ctx->ws, 4); releaseTempMatrices(ctx->ws, 4);
} }
void drawBoxes2(DrawingContext *ctx) void drawBoxes2(DrawingContext *ctx)
{ {
gsl_matrix *tmp = getTempMatrix(ctx->ws); gsl_matrix *rot = getTempMatrix(ctx->ws);
gsl_matrix **gen = getTempMatrices(ctx->ws, 3); gsl_matrix **gen = getTempMatrices(ctx->ws, 3);
cairo_t *C = ctx->cairo; cairo_t *C = ctx->cairo;
cairo_save(C); cairo_save(C);
initializeTriangleGenerators(gen, ctx->cartan); initializeTriangleGenerators(gen, ctx->cartan);
int p = 9;
vector_t fp[3][3],neutral_line[3],reflection_line[p],star[2*p],outer[2];
vector_t rotation_line = {0,0,1};
cairo_set_line_width(C, 1.5/ctx->dim->scalefactor);
cairo_set_source_rgb(C, 1, 0, 0);
multiply(gen[0], gen[1], rot);
fixedPoints(ctx, "abc", fp[0]);
fixedPoints(ctx, "bca", fp[1]);
fixedPoints(ctx, "cab", fp[2]);
LOOP(i) neutral_line[i] = cross(fp[i][0], fp[i][2]);
LOOP(j) reflection_line[0].x[j] = gsl_matrix_get(ctx->cartan, 0, j);
star[0] = cross(neutral_line[0],reflection_line[0]);
star[p] = cross(neutral_line[2],reflection_line[0]);
for(int j = 1; j < p; j++) {
reflection_line[j] = apply_transpose(rot, reflection_line[j-1]);
star[j] = apply(rot, star[j-1]);
star[j+p] = apply(rot, star[j+p-1]);
}
outer[0] = cross(neutral_line[0],reflection_line[5]);
outer[1] = cross(neutral_line[2],reflection_line[5]);
for(int j = 0; j < 8; j++) {
drawVector(ctx, star[j]);
drawVector(ctx, star[p+j]);
}
for(int j = 0; j < 7; j++) {
// if(j == 3)
// continue;
drawSegment(ctx, star[j%p], star[(j+1)%p+p]);
drawSegment(ctx, star[(j+1)%p+p], star[(j+1)%p]);
drawSegment(ctx, star[(j+1)%p], star[j%p+p]);
drawSegment(ctx, star[j%p+p], star[j%p]);
}
cairo_set_source_rgb(C, 0, 0, 1);
drawVector(ctx,outer[0]);
drawVector(ctx,outer[1]);
// drawCovector(ctx, neutral_line[0]);
// drawCovector(ctx, neutral_line[2]);
drawSegment(ctx, star[0], star[p]);
drawSegment(ctx, star[p], outer[1]);
drawSegment(ctx, outer[1], outer[0]);
drawSegment(ctx, outer[0], star[0]);
cairo_set_source_rgb(C, 0, 0, 0);
drawCovector(ctx, rotation_line);
// for(int j = 0; j < 5; j++)
// drawCovector(ctx, reflection_line[j]);
// 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]));
// drawPolygon(ctx, 1, 4, p[0][0], i[0], p[1][0], i[1]);
// abc, ababcba, abababcbaba, ..., cab // abc, ababcba, abababcbaba, ..., cab
// bca, acaba, abacababa, ..., babcb // bca, acaba, abacababa, ..., babcb
/*
vector_t v[4][3]; vector_t v[4][3];
vector_t i[4]; vector_t i[4];
@ -781,20 +709,13 @@ void drawBoxes2(DrawingContext *ctx)
// drawPolygon(ctx, 1, 6, v[2][2], v[1][1], v[0][1], v[3][2], v[3][1], v[2][1]); // drawPolygon(ctx, 1, 6, v[2][2], v[1][1], v[0][1], v[3][2], v[3][1], v[2][1]);
// drawPolygon(ctx, 1, 6, v[1][2], i[1], i[2], i[0], v[0][2], i[3]); // drawPolygon(ctx, 1, 6, v[1][2], i[1], i[2], i[0], v[0][2], i[3]);
/*
cairo_set_source_rgb(C, 1, 0, 0);
drawBox(ctx, "cab", "bca");
cairo_set_source_rgb(C, 1, 0.5, 0);
drawBox(ctx, "bc bca cb", "bc abc cb");
drawBox(ctx, "bcbc bca cbcb", "bcbc abc cbcb");
drawBox(ctx, "bcbcbc bca cbcbcb", "bcbcbc abc cbcbcb");
drawBox(ctx, "bcbcbcbc bca cbcbcbcb", "bcbcbcbc abc cbcbcbcb");
drawBox(ctx, "bcbcbcbcbc bca cbcbcbcbcb", "bcbcbcbcbc abc cbcbcbcbcb");
*/
cairo_set_line_width(C, 1.5/ctx->dim->scalefactor); cairo_set_line_width(C, 1.5/ctx->dim->scalefactor);
cairo_set_source_rgb(C, 1, 0, 0); cairo_set_source_rgb(C, 1, 0, 0);
drawBox(ctx, "bca", "abc"); // drawBox(ctx, "bca", "abc");
drawCurvedBox(ctx, 'A', "");
*/
/*
cairo_set_source_rgb(C, 1, 0.5, 0); cairo_set_source_rgb(C, 1, 0.5, 0);
drawBox(ctx, "ab abc ba", "ab cab ba"); drawBox(ctx, "ab abc ba", "ab cab ba");
drawBox(ctx, "abab abc baba", "abab cab baba"); drawBox(ctx, "abab abc baba", "abab cab baba");
@ -806,50 +727,7 @@ void drawBoxes2(DrawingContext *ctx)
drawBox(ctx, "babab abc babab", "babab cab babab"); drawBox(ctx, "babab abc babab", "babab cab babab");
drawBox(ctx, "bababab abc bababab", "bababab cab bababab"); drawBox(ctx, "bababab abc bababab", "bababab cab bababab");
// drawBox(ctx, "babababab abc babababab", "babababab cab babababab"); // drawBox(ctx, "babababab abc babababab", "babababab cab babababab");
*/
/*
cairo_set_source_rgb(C, 1, 0, 0);
drawBox(ctx, "ab ca cab ac ba", "ab ca bca ac ba");
drawBox(ctx, "ab caca cab acac ba", "ab caca bca acac ba");
drawBox(ctx, "ab cacaca cab acacac ba", "ab cacaca bca acacac ba");
drawBox(ctx, "ab cacacaca cab acacacac ba", "ab cacacaca bca acacacac ba");
drawBox(ctx, "ab cacacacaca cab acacacacac ba", "ab cacacacaca bca acacacacac ba");
*/
/*
drawBox(ctx, "ab abc ba", "ab cab ba");
drawBox(ctx, "abab abc baba", "abab cab baba");
drawBox(ctx, "ababab abc bababa", "ababab cab bababa");
drawBox(ctx, "abababab abc babababa", "abababab cab babababa");
drawBox(ctx, "ababababab abc bababababa", "ababababab cab bababababa");
*/
// abc -> arar abc r-ar-a = (ar)³
// bca -> (ar)² (ra)³ (ar)-² -> a rarr a rar- r-ar rar- a = ababcba
// a rar- r-ar a r-ar a rar- a r-ar ra-r a = abcacabacba
// drawBox(ctx, "ab ca cab ac ba", "ab ca bca ac ba");
// drawBox(ctx, "ab ca bc bca cb ac ba", "ab ca bc abc cb ac ba");
// drawBox(ctx, "ab ca bc ab abc ba cb ac ba", "ab ca bc ab cab ba cb ac ba");
// these are the right boxes
/*
cairo_set_source_rgb(C, 1, 0.5, 0);
drawBox(ctx, "abababab abc babababa", "abababab cab babababa");
drawBox(ctx, "ababab abc bababa", "ababab cab bababa");
drawBox(ctx, "abab abc baba", "abab cab baba");
drawBox(ctx, "ab abc ba", "ab cab ba");
drawBox(ctx, "b abc b", "b cab b");
drawBox(ctx, "bab abc bab", "bab cab bab");
drawBox(ctx, "babab abc babab", "babab cab babab");
drawBox(ctx, "bababab abc bababab", "bababab cab bababab");
*/
// drawBox(ctx, "ab a cab a ba", "ab a bca a ba");
// drawBox(ctx, "ab ca cab ac ba", "ab ca bca ac ba");
// drawBox(ctx, "cab", "bca");
// drawBox(ctx, "ca cab ac", "ca bca ac");
cairo_restore(C); cairo_restore(C);
releaseTempMatrices(ctx->ws, 4); releaseTempMatrices(ctx->ws, 4);

1
main.c
View File

@ -25,6 +25,7 @@ void setupContext(DrawingContext *ctx)
ctx->k[1] = 4; ctx->k[1] = 4;
ctx->k[2] = 4; ctx->k[2] = 4;
ctx->parameter = 5.35; ctx->parameter = 5.35;
// ctx->parameter = 2.77;
// ctx->parameter = 0.1; // ctx->parameter = 0.1;
ctx->show_boxes = 0; ctx->show_boxes = 0;
ctx->show_boxes2 = 0; ctx->show_boxes2 = 0;