Fix alan
This commit is contained in:
@@ -1,14 +1,21 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define PI 3.14159265358979323846
|
#ifndef M_PI
|
||||||
#define GRID_SIZE 256
|
#define M_PI 3.14159265358979323846
|
||||||
#define WIDTH 0.5 // Ancho de la cinta de Möbius
|
#endif
|
||||||
|
|
||||||
void getMobiusPoint(float *p, int i, int j) {
|
#define GRID_SIZE 16
|
||||||
float u = (2*PI) * ( (float)i/(GRID_SIZE+1) );
|
#define WIDTH 0.5
|
||||||
float v = (2*WIDTH) * ((float)j/(GRID_SIZE+1) ) - WIDTH;
|
|
||||||
|
typedef void(*function_t)(float*,int,int);
|
||||||
|
|
||||||
|
void mobius(float *p, int i, int j)
|
||||||
|
{
|
||||||
|
float u = (2*M_PI) * ((float)i/(GRID_SIZE) );
|
||||||
|
float v = (2*WIDTH) * ((float)j/(GRID_SIZE) ) - WIDTH;
|
||||||
|
|
||||||
p[0] = cos(u) + v * cos(u / 2) * cos(u);
|
p[0] = cos(u) + v * cos(u / 2) * cos(u);
|
||||||
p[1] = sin(u) + v * cos(u / 2) * sin(u);
|
p[1] = sin(u) + v * cos(u / 2) * sin(u);
|
||||||
@@ -16,10 +23,11 @@ void getMobiusPoint(float *p, int i, int j) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float * acabron(){
|
float * acabron(){
|
||||||
int k=0;
|
long size = GRID_SIZE*GRID_SIZE*2*3*3;
|
||||||
long size = GRID_SIZE*GRID_SIZE*2*3;
|
function_t f = mobius;
|
||||||
|
|
||||||
float * d_cube;
|
float * d_cube;
|
||||||
|
int k=0;
|
||||||
|
|
||||||
d_cube = malloc((size+1)*sizeof(float));
|
d_cube = malloc((size+1)*sizeof(float));
|
||||||
d_cube[0] = size;
|
d_cube[0] = size;
|
||||||
|
|
||||||
@@ -28,21 +36,24 @@ float * acabron(){
|
|||||||
for (int j = 0; j < GRID_SIZE; j++)
|
for (int j = 0; j < GRID_SIZE; j++)
|
||||||
{
|
{
|
||||||
// Triángulo 1
|
// Triángulo 1
|
||||||
getMobiusPoint(&d_cube[k + 1], i, j);
|
f(&d_cube[k + 1], i, j);
|
||||||
getMobiusPoint(&d_cube[k + 2], i + 1, j);
|
k+=3;
|
||||||
getMobiusPoint(&d_cube[k + 3], i + 1, j + 1);
|
f(&d_cube[k + 1], i + 1, j);
|
||||||
|
k+=3;
|
||||||
|
f(&d_cube[k + 1], i + 1, j + 1);
|
||||||
|
k+=3;
|
||||||
|
|
||||||
// Triángulo 2
|
// Triángulo 2
|
||||||
getMobiusPoint(&d_cube[k + 4], i, j);
|
f(&d_cube[k + 1], i, j);
|
||||||
getMobiusPoint(&d_cube[k + 5], i, j + 1);
|
k+=3;
|
||||||
getMobiusPoint(&d_cube[k + 6], i + 1, j + 1);
|
f(&d_cube[k + 1], i, j + 1);
|
||||||
|
k+=3;
|
||||||
// Imprimir los triángulos generados
|
f(&d_cube[k + 1], i + 1, j + 1);
|
||||||
k+=6;
|
k+=3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return d_cube;
|
return d_cube;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "data/axis.h"
|
#include "data/axis.h"
|
||||||
#include "data/shaders.h"
|
#include "data/shaders.h"
|
||||||
|
#include <stdlib.h>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define WIDTH 512
|
#define WIDTH 512
|
||||||
#define HEIGHT 512
|
#define HEIGHT 512
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user