Fix: trous, the good one
This commit is contained in:
@@ -6,14 +6,13 @@
|
|||||||
#define M_PI 3.14159265358979323846
|
#define M_PI 3.14159265358979323846
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define WIDTH 0.5
|
|
||||||
|
|
||||||
typedef void(*function_t)(float*,int, int, int);
|
typedef void(*function_t)(float*,int, int, int);
|
||||||
|
|
||||||
void mobius(float *d_surface, int i, int j, int grid_size)
|
void mobius(float *d_surface, int i, int j, int grid_size)
|
||||||
{
|
{
|
||||||
float u = (2*M_PI) * ((float)i/(grid_size) );
|
const float width = 0.5;
|
||||||
float v = (2*WIDTH) * ((float)j/(grid_size) ) - WIDTH;
|
float u = (2*M_PI) * ((float)i/grid_size );
|
||||||
|
float v = (2*width) * ((float)j/grid_size ) - width;
|
||||||
|
|
||||||
d_surface[0] = cos(u) + v * cos(u / 2) * cos(u);
|
d_surface[0] = cos(u) + v * cos(u / 2) * cos(u);
|
||||||
d_surface[1] = sin(u) + v * cos(u / 2) * sin(u);
|
d_surface[1] = sin(u) + v * cos(u / 2) * sin(u);
|
||||||
@@ -22,11 +21,11 @@ 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*M_PI) * ((float)i/(grid_size) );
|
float u = (2.0*M_PI) * ((float)i/grid_size );
|
||||||
float v = (1*WIDTH) * ((float)j );
|
float v = (2.0*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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user