diff --git a/src/surface.c b/src/surface.c index 04da2dc..7f2bed8 100644 --- a/src/surface.c +++ b/src/surface.c @@ -14,6 +14,24 @@ #define CMPLX(a,b) (a+I*b) #endif +const int dim = 6; + +int factorial(int n) +{ + if(n == 1) + return 1; + + return n * factorial(n - 1); +} + +int numero_caras(int n) +{ + if(n == 2) + return 1; + + return (1 << (n - 3)) * factorial(n) / factorial(n - 2); +} + void riemman(float *d_surface, int * coords, int grid_size) { complex double eq; @@ -31,10 +49,8 @@ void riemman(float *d_surface, int * coords, int grid_size) void cube( float *d_surface, int * coord, int grid_size ) { - unsigned char i; - - for(int i=0; i<3; i++ ) - d_surface[i]=(float)coord[i]/grid_size; + for(int i = 0; i < dim; i++ ) + d_surface[i] = ((float)coord[i]/grid_size) - 0.5; } void mobius(float *d_surface, int * coord, int grid_size) @@ -73,18 +89,17 @@ typedef void (*function_t)(float *, int *, int); float *generate_data_surface(int grid_size, unsigned char *s) { - unsigned int i, j, k, o, p, l, n, m; - long size, q=0; + unsigned int i, j, k, o, p, n; + long size, q = 0; function_t f; float *d_surface; - const int dim =3; int cara[dim]; f =cube ; - *s = 3; + *s = 6; - size = grid_size * grid_size * 6 * (*s) * 6; + size = grid_size * grid_size * 6 * (*s) * numero_caras(dim); d_surface = malloc((size + 1) * sizeof(float)); d_surface[0] = size;