WIP: coord centre dans un cube 7x7x7

This commit is contained in:
Jean Sirmai 2023-08-20 00:02:45 +02:00
parent 57df848820
commit bdbbdc5915
Signed by: jean
GPG Key ID: FB3115C340E057E3
3 changed files with 27 additions and 21 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

View File

@ -331,11 +331,13 @@ static void diagonal_test(int x, int y, int z,
}
static void draw_a_central_star(GLuint *lines_origin, int n)
static int draw_a_central_star(GLuint *lines_origin, int n)
{
printf("(%d) ",n);
draw_line (lines_origin, n + 0, n + 1);
draw_line (lines_origin, n + 2, n + 3);
draw_line (lines_origin, n + 4, n + 5);
return n;
}
@ -400,7 +402,7 @@ static void draw_EW_ZA_SN_in_a_cubic_space(GLuint *lines_origin, int n, int side
draw_a_central_star (lines_origin, n + (s - z) * 6); // N
}
static void draw_a_central_central_star(GLuint *lines_origin, int n, int side_size)
static int draw_a_central_central_star(GLuint *lines_origin, int n, int side_size)
{
/* DANS UN CUBE DE COTE 3 LE CENTRE EST À 3 x 3 x 3 = 27 / 2 = 13,5 >> 13 * 6
* DANS UN CUBE DE COTE 5 LE CENTRE EST À 5 x 5 x 5 = 125 / 2 = 62,5 >> 62 * 6
@ -409,8 +411,8 @@ static void draw_a_central_central_star(GLuint *lines_origin, int n, int side_si
* JE CHOISIS DES CUBES AYANT DES COTÉS IMPAIRS POUR QU'IL Y AIT UNE CASE CENTRALE
*/
int s = side_size * side_size * side_size / 2;
draw_a_central_star(lines_origin, n + s * 6);
printf("draw_a_central_central_star > ");
return draw_a_central_star(lines_origin, n + s * 6);
}
static float radius(int x, int y, int z, int space_X, int space_Y, int space_Z){
@ -421,14 +423,19 @@ static float radius(int x, int y, int z, int space_X, int space_Y, int space_Z){
return r;
}
// (1,2,2) (2,1,2) (2,2,1) (2,2,2) (2,2,3) (2,3,2) (3,2,2)
#define D 0
static void draw_central_stars_in_neighbooring_cubes(GLuint *lines_origin,
static int draw_central_stars_in_neighbooring_cubes(GLuint *lines_origin,
int space_X, int space_Y, int space_Z, int step_x, int step_y)
{
float r = 0.0f, limit = 1.1f;
float r = 0.0f, limit = 1.0f;
int nb_in_neighborhood = 0;
int s = space_X * space_Y * space_Z / 2;
printf("buffers : with limit = %3.1f space units, neighborhood size = %d/%d ",\
limit, nb_in_neighborhood, s * 2 + 1);
// int z = space_Z;
// int y = z * space_Z;
// int x = y * space_Y;
@ -440,7 +447,7 @@ static void draw_central_stars_in_neighbooring_cubes(GLuint *lines_origin,
r = radius(i, j, k, space_X, space_Y, space_Z);
if (r < limit){ // 2.5f
if (D) printf("%6.3f (%d,%d,%d) ", r, i, j, k);
draw_a_central_star(lines_origin, s + (i * step_x + j * step_y + k) * 6 + 10);
return draw_a_central_star(lines_origin, s + (i * 64 + (j + 1) * 8 + (k + 1)) * 6 - 1);
/* printf("buffers : (444) n = %d i * step_x + j * step_y + k = %d 125 / 2 = %d\n",\
s + (i * step_x + j * step_y + k) * 6 + 10, i * step_x + j * step_y + k, 125/2);
*/
@ -451,8 +458,7 @@ static void draw_central_stars_in_neighbooring_cubes(GLuint *lines_origin,
}
if (D) printf("\n ");
}
printf("buffers : neighborhood size = %d/%d with limit = %3.1f space units ",\
nb_in_neighborhood, s * 2 + 1, limit);
return 0;
}
// I'm standing on Earth (any planet or star or spinning spheroid, in fact)
@ -488,13 +494,14 @@ bool compute_space(int space_X, int space_Y, int space_Z,
for (int i = 0; i < space_X * space_Y * space_Z; i ++) draw_a_central_star (lines_origin, s + i * 6);
int CUBE = 0, side_size = 0;
if ((space_X == space_Y) && (space_X == space_Z)) CUBE = 1;
int ad_hoc = 0;
if (CUBE) side_size = space_X; /* IF IT IS A CUBE, space_x = space_y = space_z */
if (1) draw_central_stars_in_neighbooring_cubes(lines_origin, space_X, space_Y, space_Z, step_x, step_y);
if (0 && CUBE) draw_a_central_central_star (lines_origin, s, side_size);
if (1) ad_hoc = draw_central_stars_in_neighbooring_cubes(lines_origin, space_X, space_Y, space_Z, step_x, step_y);
if (CUBE) draw_a_central_central_star (lines_origin, s, side_size);
if (0 && CUBE) draw_EW_ZA_SN_in_a_cubic_space (lines_origin, s, side_size);
if (0 && CUBE) draw_3_x_4_around_6_poles (lines_origin, s, side_size);
printf("space (%d x %d x %d) steps [ %d | %d | %d ]",\
space_X, space_Y, space_Z, (space_Z + 1) * (space_Y + 1), space_Z + 1, 1);
printf("DELTA = %d - %d = %d\nspace (%d x %d x %d) steps [ %d | %d | %d ]",\
s + side_size * 6, ad_hoc, s + side_size * 6 - ad_hoc, space_X, space_Y, space_Z, (space_Z + 1) * (space_Y + 1), space_Z + 1, 1);
if (pref_test_diagonal) diagonal_test (space_X, space_Y, space_Z, step_x, step_y, step_z, lines_origin);
printf(" >>> prochain objectif : dessiner un voisinage de Moore 3D sphérique.\n");
return 0;

View File

@ -550,9 +550,9 @@ GLuint arrows[] = {
static void get_model_data_and_user_preferences(){
space_X = 5; // 0 < space_X assert TODO
space_Y = 5; // 0 < space_Y assert TODO
space_Z = 5; // 0 < space_Z assert TODO
space_X = 7; // 0 < space_X assert TODO
space_Y = 7; // 0 < space_Y assert TODO
space_Z = 7; // 0 < space_Z assert TODO
cubes_nb = space_X * space_Y * space_Z;
pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc.
// xyz, 0, x, y, z, xy, xz, yz, xyz (repeat)
@ -659,11 +659,10 @@ static void compute_buffers_sizes(int space_X, int space_Y, int space_Z,
if (pref_show_grid > 0) buffer_lines_size += 12 * 2; // space ridges
// sinon, les arêtes de l'espace sont tracées par les grilles
if (pref_test_diagonal) buffer_lines_size += 2; // la diagonale test [0 - max]
buffer_lines_size += 6 * pref_central_stars_nb + 6; // test central stars
buffer_lines_size += 6 * pref_central_stars_nb; // test central stars
buffer_lines_size -= 2; // == TESTS LINES BUFFER SIZE ON THE DIAGONAL
// if (pref_test_diagonal) buffer_lines_size += 2;
// TESTS LINES BUFFER SIZE ON THE DIAGONAL [0 - max]
if (0) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\
%4d/2 = %3d lines, %4d/3 = %3d plans.\n",