habemos botella de klein

This commit is contained in:
alan
2024-10-18 15:01:38 -06:00
parent 5f392792c5
commit 7d3f8f71b2
2 changed files with 15 additions and 4 deletions

View File

@@ -35,7 +35,7 @@ int main( void )
glewInit(); glewInit();
points = generate_surface(256); points = generate_surface(16);
if( !( shader = create_shader() ) ) if( !( shader = create_shader() ) )
goto error_shader; goto error_shader;

View File

@@ -21,18 +21,29 @@ void mobius(float *d_surface, int i, int j, int grid_size)
void toro(float *d_surface, int i, int j, int grid_size) void toro(float *d_surface, int i, int j, int grid_size)
{ {
float u = (2.0*M_PI) * ((float)i/grid_size ); float u = (2*M_PI) * ((float)i/grid_size );
float v = (2.0*M_PI) * ((float)j/grid_size ); float v = (2*M_PI) * ((float)j/grid_size );
d_surface[0] = (1 + 0.5*cos(v))*cos(u); d_surface[0] = (1 + 0.5*cos(v))*cos(u);
d_surface[1] = (1 + 0.5*cos(v))*sin(u); d_surface[1] = (1 + 0.5*cos(v))*sin(u);
d_surface[2] = 0.5*sin(v); d_surface[2] = 0.5*sin(v);
} }
void klein(float *d_surface, int i, int j, int grid_size)
{
float u = (2*M_PI) * ((float)i/grid_size );
float v = (2*M_PI) * ((float)j/grid_size );
d_surface[0] = (0.5*cos(v) + 0.5) * cos(u);
d_surface[1] = (0.5*cos(v) + 0.5) * sin(u);
d_surface[2] = sin(v) * cos(u/2);
//d_surface[2] = sin(v)*sin(u/2);
}
float * generate_surface(int grid_size) float * generate_surface(int grid_size)
{ {
long size = grid_size*grid_size*2*3*3; long size = grid_size*grid_size*2*3*3;
function_t f = toro; function_t f = klein;
float * d_surface; float * d_surface;
int k=0; int k=0;