triangle_group_limit_set/main.h

128 lines
3.7 KiB
C
Raw Permalink Normal View History

2019-02-03 12:18:14 +00:00
#ifndef TRIANGLE_GROUP_MAIN_H
#define TRIANGLE_GROUP_MAIN_H
2019-02-24 07:43:52 +00:00
#include <gsl/gsl_linalg.h>
2019-02-03 12:18:14 +00:00
#include "triangle.h"
#include "linalg.h"
#include "initcairo.h"
#undef ERROR
#define ERROR(condition, msg, ...) if(condition){fprintf(stderr, msg, ##__VA_ARGS__); exit(1);}
#define LOOP(i) for(int i = 0; i < 3; i++)
#define NUM_GROUP_ELEMENTS 10000
#define NUM_GROUP_ELEMENTS_COMBINATORIAL 100000
// (0,1) -> 2, (1,2) -> 0, (2,0) -> 1
// (1,0) -> 5, (2,1) -> 3, (0,2) -> 4
#define ROTATION_LETTER(x,y) (((y)-(x)+3)%3 == 1 ? ((y)+1)%3 : ((x)+1)%3+3)
2019-02-03 12:18:14 +00:00
typedef struct {
double x[3];
} vector_t;
typedef struct {
double x;
double y;
} point_t;
typedef struct {
// infos about the screen to draw on
cairo_t *cairo;
DimensionsInfo *dim;
// a priori parameter
int p[3],k[3];
double parameter;
double parameter2;
2023-02-05 20:10:16 +00:00
char *movie_filename;
double movie_parameter_duration;
double movie_parameter2_duration;
int movie_n_frames;
2019-02-03 12:18:14 +00:00
int n_group_elements;
int n_group_elements_combinatorial;
2019-02-03 12:18:14 +00:00
int show_boxes;
2019-02-08 12:03:05 +00:00
int show_boxes2;
2019-02-03 12:18:14 +00:00
int show_attractors;
int show_reflectors;
2019-12-23 11:29:50 +00:00
int show_rotated_reflectors;
2019-02-03 12:18:14 +00:00
int show_limit;
2019-12-23 11:29:50 +00:00
int show_dual_limit;
int show_text;
2021-11-05 13:11:06 +00:00
int mode;
2019-02-11 14:20:56 +00:00
int use_rotation_basis;
2019-02-03 12:18:14 +00:00
int limit_with_lines;
2021-11-05 13:11:06 +00:00
int show_marking;
point_t marking;
int show_coxeter_orbit;
2019-02-03 12:18:14 +00:00
int use_repelling;
gsl_matrix *cartan, *cob;
// precomputed and constant
groupelement_t *group;
// computed stuff
double *limit_curve; // x, y, angle triples
2019-12-23 11:29:50 +00:00
int limit_curve_count;
2019-02-03 12:18:14 +00:00
// temporary; matrices can only be freed from the top, but that's enough for us
workspace_t *ws;
} DrawingContext;
2019-12-23 11:29:50 +00:00
typedef enum {
VT_POINT,
VT_LINE
} vector_type_t;
2019-02-03 12:18:14 +00:00
// implemented in limit_set.c
void cartanMatrix(gsl_matrix *cartan, double a1, double a2, double a3, double s);
void initializeTriangleGenerators(gsl_matrix **gen, double a1, double a2, double a3, double s, double t, workspace_t *ws);
void initializeTriangleGeneratorsCurrent(gsl_matrix **gen, DrawingContext *ctx);
2019-02-03 12:18:14 +00:00
int computeLimitCurve(DrawingContext *ctx);
// implemented in draw.c
vector_t cross(vector_t a, vector_t b);
int fixedPoints(DrawingContext *ctx, const char *word, vector_t *out);
void drawPoint(DrawingContext *ctx, point_t p);
void drawSegment2d(DrawingContext *ctx, point_t a, point_t b);
2021-11-05 13:11:06 +00:00
point_t vectorToPoint(DrawingContext *ctx, vector_t v);
2019-02-03 12:18:14 +00:00
void drawVector(DrawingContext *ctx, vector_t v);
void drawCovector(DrawingContext *ctx, vector_t v);
void drawSegment(DrawingContext *ctx, vector_t a, vector_t b);
2019-02-11 14:20:56 +00:00
void drawPolygon(DrawingContext *ctx, int segments, int sides, ...);
2019-02-03 12:18:14 +00:00
void drawTriangle(DrawingContext *ctx, const char *word);
void drawBox(DrawingContext *ctx, const char *word1, const char *word2);
2019-02-11 14:28:37 +00:00
void drawBoxLines(DrawingContext *ctx, const char *word1, const char *word2);
2019-02-03 12:18:14 +00:00
void drawBoxStd(DrawingContext *ctx, const char *word, char base);
void drawReflectors(DrawingContext *ctx);
void drawAttractors(DrawingContext *ctx);
void drawBoxes(DrawingContext *ctx);
2019-02-08 12:03:05 +00:00
void drawBoxes2(DrawingContext *ctx);
2019-02-03 12:18:14 +00:00
void drawLimitCurve(DrawingContext *ctx);
void drawText(DrawingContext *ctx);
void draw(DrawingContext *ctx);
// implemented in main.c
2021-11-05 13:11:06 +00:00
void setupContext(DrawingContext *ctx, int argc, char *argv[]);
2019-02-03 12:18:14 +00:00
void destroyContext(DrawingContext *ctx);
void print(DrawingContext *screen);
int processEvent(GraphicsInfo *info, XEvent *ev);
void computeMatrix(DrawingContext *ctx, gsl_matrix *result, const char *type);
void computeRotationMatrixFrame(DrawingContext *ctx, gsl_matrix *result, const char *type);
2019-02-03 12:18:14 +00:00
void updateMatrices(DrawingContext *ctx);
2019-02-24 07:43:52 +00:00
static vector_t vectorFromGsl(gsl_vector *v)
{
vector_t result;
LOOP(i) result.x[i] = gsl_vector_get(v, i);
return result;
}
static void vectorToGsl(vector_t v, gsl_vector *out)
{
LOOP(i) gsl_vector_set(out, i, v.x[i]);
}
2019-02-03 12:18:14 +00:00
#endif