curved boxes

This commit is contained in:
Florian Stecker 2020-01-11 09:35:47 -05:00
parent 0cde265d1e
commit f257364907
1 changed files with 183 additions and 22 deletions

205
draw.c
View File

@ -218,6 +218,8 @@ void drawBoxLines(DrawingContext *ctx, const char *word1, const char *word2)
drawPolygon(ctx, 0, 4, p[0][0], i[0], p[1][0], i[1]);
}
void drawBoxStd(DrawingContext *ctx, const char *word, char base)
{
char word1[100];
@ -384,8 +386,6 @@ void drawArc(DrawingContext *ctx, const char *word, vector_t start, vector_type_
angle_end_delta = acos(-fabs(gsl_vector_get(vector_in_frame, 2))/radius/
sqrt(gsl_vector_get(vector_in_frame, 0)*gsl_vector_get(vector_in_frame, 0) +
gsl_vector_get(vector_in_frame, 1)*gsl_vector_get(vector_in_frame, 1)));
printf("angle_end_delta: %f\n", angle_end_delta);
}
int previous_inside = 0;
@ -408,9 +408,6 @@ void drawArc(DrawingContext *ctx, const char *word, vector_t start, vector_type_
if(i%2)
FLIP(angle_start_final, angle_end_final);
printf("start: %f, end: %f, other: %f, third: %f\n", angle_start_final, angle_end_final, angle_end_other, angle_third);
printf("interval1: %d, interval2: %d, diff: %f %f %f\n", ANGLE_IN_INTERVAL(angle_start, angle_end_final, angle_end_other), ANGLE_IN_INTERVAL(angle_start_final, angle_end_final, angle_third), ANGLE_DIFF(angle_end_final, angle_start_final), ANGLE_DIFF(angle_end_other, angle_start_final), ANGLE_DIFF(angle_third, angle_start_final));
if(endtype == VT_LINE && ANGLE_IN_INTERVAL(angle_start_final, angle_end_final, angle_end_other))
continue;
if(contain && !ANGLE_IN_INTERVAL(angle_start_final, angle_end_final, angle_third))
@ -421,9 +418,6 @@ void drawArc(DrawingContext *ctx, const char *word, vector_t start, vector_type_
break;
}
// printf("angle_start: %f, angle_end: %f, angle_third: %f\n", angle_start, angle_end, angle_third);
for(int k = 0; k <= iterations; k++) {
angle = angle_start_final + (double)k/(double)iterations * ANGLE_DIFF(angle_end_final, angle_start_final);
@ -490,25 +484,59 @@ void drawAttractors(DrawingContext *ctx)
}
}
void drawCurvedBox(DrawingContext *ctx)
char *conjugate_word(const char *word, int modifier, const char *conj, char *buffer)
{
int wordlen = strlen(word);
int conjlen = strlen(conj);
for(int i = 0; i < conjlen; i++) {
buffer[i] = conj[i];
buffer[2*conjlen+wordlen-1-i] = conj[i];
}
for(int i = 0; i < wordlen; i++) {
if(word[i] == ' ')
buffer[conjlen+i] = word[i];
else
buffer[conjlen+i] = (word[i]+modifier-'a')%3 + 'a';
}
buffer[2*conjlen + wordlen] = 0;
return buffer;
}
void drawCurvedBox(DrawingContext *ctx, int base, const char *conj)
{
vector_t p[6][3];
vector_t l[2][3];
char word[100];
int modifier = base - 'A';
fixedPoints(ctx, "abc", p[0]);
fixedPoints(ctx, "bca", p[1]);
fixedPoints(ctx, "babcb", p[2]);
fixedPoints(ctx, "ababcba", p[3]);
fixedPoints(ctx, "bacac abc cacab", p[4]);
fixedPoints(ctx, "abacac abc cacaba", p[5]);
conjugate_word("abc", modifier, conj, word);
fixedPoints(ctx, word, p[0]);
conjugate_word("bca", modifier, conj, word);
fixedPoints(ctx, word, p[1]);
conjugate_word("b abc b", modifier, conj, word);
fixedPoints(ctx, word, p[2]);
conjugate_word("ab abc ba", modifier, conj, word);
fixedPoints(ctx, word, p[3]);
conjugate_word("baca cab acab", modifier, conj, word);
fixedPoints(ctx, word, p[4]);
conjugate_word("abaca cab acaba", modifier, conj, word);
fixedPoints(ctx, word, p[5]);
LOOP(j) l[0][j] = cross(p[0][(3-j)%3], p[0][(4-j)%3]);
LOOP(j) l[1][j] = cross(p[1][(3-j)%3], p[1][(4-j)%3]);
drawArc(ctx, "ab", p[0][0], VT_POINT, p[2][0], VT_POINT, p[1][0], 0);
drawArc(ctx, "bcab", p[2][0], VT_POINT, l[1][0], VT_LINE, p[4][0], 1);
drawArc(ctx, "ab", p[1][0], VT_POINT, p[3][0], VT_POINT, p[0][0], 0);
drawArc(ctx, "abcaba", p[3][0], VT_POINT, l[0][0], VT_LINE, p[5][0], 1);
conjugate_word("ab", modifier, conj, word);
drawArc(ctx, word, p[0][0], VT_POINT, p[2][0], VT_POINT, p[1][0], 0);
conjugate_word("bcab", modifier, conj, word);
drawArc(ctx, word, p[2][0], VT_POINT, l[1][0], VT_LINE, p[4][0], 1);
conjugate_word("ab", modifier, conj, word);
drawArc(ctx, word, p[1][0], VT_POINT, p[3][0], VT_POINT, p[0][0], 0);
conjugate_word("abcaba", modifier, conj, word);
drawArc(ctx, word, p[3][0], VT_POINT, l[0][0], VT_LINE, p[5][0], 1);
drawCovector(ctx, l[0][0]);
drawCovector(ctx, l[1][0]);
@ -520,8 +548,9 @@ void drawBoxes(DrawingContext *ctx)
gsl_matrix *rot = getTempMatrix(ctx->ws);
gsl_matrix **gen = getTempMatrices(ctx->ws, 3);
cairo_t *C = ctx->cairo;
cairo_save(C);
vector_t p[6][3];
vector_t p[22][3];
vector_t l[6][3];
vector_t alpha[6];
@ -534,9 +563,140 @@ void drawBoxes(DrawingContext *ctx)
for(int i = 0; i < 6; 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);
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);
drawCurvedBox(ctx);
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_source_rgb(C, 0, 0, 0);
drawCurvedBox(ctx, 'A', "");
// drawRotationOrbit(ctx, "ab", p[1][0]);
cairo_set_source_rgb(C, 1.0, 0, 0);
// drawCurvedBox(ctx, 'B', "abca");
// drawCurvedBox(ctx, 'A', "abcabc");
// drawRotationOrbit(ctx, "ab", p[1][0]);
// drawCurvedBox(ctx, 'C', "");
// drawCurvedBox(ctx, 'C', "b");
// drawCurvedBox(ctx, 'C', "bab");
// drawCurvedBox(ctx, 'C', "babab");
// drawCurvedBox(ctx, 'C', "bababab");
// drawCurvedBox(ctx, 'C', "ababababab");
// drawCurvedBox(ctx, 'C', "abababababab");
// drawCurvedBox(ctx, 'C', "ababababababab");
// drawCurvedBox(ctx, 'C', "abababababababab");
/*
drawRotationOrbit(ctx, "ca", p[0][0]);
@ -590,6 +750,7 @@ void drawBoxes(DrawingContext *ctx)
alpha[3] = apply_transpose(gen[1], alpha[0]);
drawCovector(ctx, alpha[3]);
*/
cairo_restore(C);
releaseTempMatrices(ctx->ws, 4);
}
@ -795,7 +956,7 @@ void drawLimitCurve(DrawingContext *ctx)
cairo_save(C);
cairo_set_source_rgb(C, 0, 0, 0);
cairo_set_source_rgb(C, 0.5, 0.5, 0.5);
if(ctx->limit_with_lines) {
int previous_inside = 0;