WIP: une approche par step_x, _y, _z <> commit avant de repartir

This commit is contained in:
Jean Sirmai 2023-08-20 14:31:43 +02:00
parent 0b1fed686e
commit d8065ecf5f
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 73 additions and 31 deletions

View File

@ -333,7 +333,6 @@ static void diagonal_test(int x, int y, int z,
static int 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 + 0, n + 1);
draw_line (lines_origin, n + 2, n + 3); draw_line (lines_origin, n + 2, n + 3);
draw_line (lines_origin, n + 4, n + 5); draw_line (lines_origin, n + 4, n + 5);
@ -402,7 +401,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 draw_a_central_star (lines_origin, n + (s - z) * 6); // N
} }
static int draw_a_central_central_star(GLuint *lines_origin, int n, int side_size) static int draw_a_central_central_star(GLuint *lines_origin, int s, 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 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 * DANS UN CUBE DE COTE 5 LE CENTRE EST À 5 x 5 x 5 = 125 / 2 = 62,5 >> 62 * 6
@ -410,9 +409,9 @@ static int draw_a_central_central_star(GLuint *lines_origin, int n, int side_siz
* ETC. * ETC.
* JE CHOISIS DES CUBES AYANT DES COTÉS IMPAIRS POUR QU'IL Y AIT UNE CASE CENTRALE * 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; int n = side_size * side_size * side_size / 2;
printf("draw_a_central_central_star > "); printf("draw_a_central_central_star > ");
return draw_a_central_star(lines_origin, n + s * 6); return draw_a_central_star(lines_origin, s + n * 6);
} }
static float radius(int x, int y, int z, int space_X, int space_Y, int space_Z){ static float radius(int x, int y, int z, int space_X, int space_Y, int space_Z){
@ -425,7 +424,45 @@ static float radius(int x, int y, int z, int space_X, int space_Y, int space_Z){
// (1,2,2) (2,1,2) (2,2,1) (2,2,2) (2,2,3) (2,3,2) (3,2,2) // (1,2,2) (2,1,2) (2,2,1) (2,2,2) (2,2,3) (2,3,2) (3,2,2)
#define D 0 /* #define D 0 */
/* static int draw_central_stars_in_neighbooring_cubes_verbose(GLuint *lines_origin, */
/* int space_X, int space_Y, int space_Z, int step_x, int step_y) */
/* { */
/* float r = 0.0f, limit = 1.0f; */
/* int nb_in_neighborhood = 0, step_z = 1; */
/* int s = space_X * space_Y * space_Z / 2; */
/* printf("buffers : with limit = %3.1f, %d/%d neighboors, ",\ */
/* limit, nb_in_neighborhood, s * 2 + 1); */
/* // int z = space_Z; */
/* // int y = z * space_Z; */
/* // int x = y * space_Y; */
/* for (int i = 0; i < space_X; i++){ */
/* for (int j = 0; j < space_Y; j++){ */
/* if (D && (i == 0 || i == space_X - 1)) printf(" "); */
/* for (int k = 0; k < space_Z; k++){ */
/* if (D && (k == 0 && j == space_X - 1)) printf(" "); */
/* 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); */
/* return draw_a_central_star(lines_origin, */
/* s + ((i + 0) * step_x */
/* + (j + 0) * step_y */
/* + (k + 0) * step_z) * 6 */
/* + 10 ); */
// 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);
// nb_in_neighborhood ++; //printf("r = %f (%d,%d,%d)\n", r, i, j ,k);
/* } */
/* } */
/* if (D) printf("\n"); */
/* } */
/* if (D) printf("\n "); */
/* } */
/* return 0; */
/* } */
static int 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) int space_X, int space_Y, int space_Z, int step_x, int step_y)
{ {
@ -433,7 +470,7 @@ static int draw_central_stars_in_neighbooring_cubes(GLuint *lines_origin,
int nb_in_neighborhood = 0, step_z = 1; int nb_in_neighborhood = 0, step_z = 1;
int s = space_X * space_Y * space_Z / 2; int s = space_X * space_Y * space_Z / 2;
printf("buffers : with limit = %3.1f space units, neighborhood size = %d/%d ",\ printf("buffers : with limit = %3.1f, %d/%d neighboors, ",\
limit, nb_in_neighborhood, s * 2 + 1); limit, nb_in_neighborhood, s * 2 + 1);
// int z = space_Z; // int z = space_Z;
@ -441,26 +478,18 @@ static int draw_central_stars_in_neighbooring_cubes(GLuint *lines_origin,
// int x = y * space_Y; // int x = y * space_Y;
for (int i = 0; i < space_X; i++){ for (int i = 0; i < space_X; i++){
for (int j = 0; j < space_Y; j++){ for (int j = 0; j < space_Y; j++){
if (D && (i == 0 || i == space_X - 1)) printf(" ");
for (int k = 0; k < space_Z; k++){ for (int k = 0; k < space_Z; k++){
if (D && (k == 0 && j == space_X - 1)) printf(" ");
r = radius(i, j, k, space_X, space_Y, space_Z); r = radius(i, j, k, space_X, space_Y, space_Z);
if (r < limit){ // 2.5f if (r < limit){ // 2.5f
if (D) printf("%6.3f (%d,%d,%d) ", r, i, j, k); int u = i * step_x + j * step_y + k * step_z, delta = 3378;
return draw_a_central_star(lines_origin, printf ("i(%d)*step_x + j(%d)*step_y + k(%d)*step_z = %d * 6 = %d delta = %d n = %d max/2 = %d",\
s + ((i + 0) * step_x i, j, k, u, u * 6, delta, s + u * 6 + delta,\
+ (j + 0) * step_y step_z * space_Z + step_y * space_Y + step_x * space_X);
+ (k + 0) * step_z) * 6 return draw_a_central_star(lines_origin, s + u * 6 + delta );
+ 10 ); nb_in_neighborhood ++;
/* 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);
*/
nb_in_neighborhood ++; //printf("r = %f (%d,%d,%d)\n", r, i, j ,k);
} }
} }
if (D) printf("\n");
} }
if (D) printf("\n ");
} }
return 0; return 0;
} }
@ -478,6 +507,15 @@ static int draw_central_stars_in_neighbooring_cubes(GLuint *lines_origin,
bool draw_some_arrows (GLuint *lines_origin, int s, int stx, int sty, bool draw_some_arrows (GLuint *lines_origin, int s, int stx, int sty,
GLuint *arrows, int arrows_nb) {return 1;} GLuint *arrows, int arrows_nb) {return 1;}
static void calcul(GLuint *lines_origin, int cote, int s){
int step_x = (cote + 1) * (cote + 1), step_y = cote + 1, step_z = 1;
int essai = step_z * cote + step_y * cote + step_x * cote;
int centre = cote * cote * cote * 3 - 3;
printf("cote = %2d essai/2 = %3d <---> (cote)3* 3 - 3 = %3d\n",\
cote, essai / 2, centre);
draw_a_central_star (lines_origin, s + centre);
}
bool compute_space(int space_X, int space_Y, int space_Z, bool compute_space(int space_X, int space_Y, int space_Z,
GLuint *arrows, int model_arrows_nb, GLuint *arrows, int model_arrows_nb,
int pref_show_grid, int pref_central_stars_nb, int pref_show_grid, int pref_central_stars_nb,
@ -493,21 +531,23 @@ bool compute_space(int space_X, int space_Y, int space_Z,
if (pref_show_grid > 0) draw_ridges_3D (space_X, space_Y, space_Z, step_x, step_y, step_z, lines_origin); if (pref_show_grid > 0) draw_ridges_3D (space_X, space_Y, space_Z, step_x, step_y, step_z, lines_origin);
draw_grids_3D(space_X, space_Y, space_Z, step_x, step_y, step_z, lines_origin, pref_show_grid); draw_grids_3D(space_X, space_Y, space_Z, step_x, step_y, step_z, lines_origin, pref_show_grid);
int s = step_z * space_Z + step_y * space_Y + step_x * space_X + 1; int s = step_z * space_Z + step_y * space_Y + step_x * space_X + 1;
if (pref_central_stars_nb == 1) draw_a_central_star (lines_origin, s + cubes_nb * 3 - 3); // if (pref_central_stars_nb == 1) draw_a_central_star (lines_origin, s + cubes_nb * 3 - 3);
if (pref_central_stars_nb == cubes_nb) if (pref_central_stars_nb == cubes_nb)
for (int i = 0; i < space_X * space_Y * space_Z; i ++) draw_a_central_star (lines_origin, s + i * 6); 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; int CUBE = 0, side_size = 0;
if ((space_X == space_Y) && (space_X == space_Z)) CUBE = 1; if ((space_X == space_Y) && (space_X == space_Z)) CUBE = 1;
int ad_hoc = 0; int ad_hoc = 0;
if (CUBE) side_size = space_X; /* IF IT IS A CUBE, space_x = space_y = space_z */ if (CUBE) side_size = space_X; /* IF IT IS A CUBE, space_x = space_y = space_z */
if (1) ad_hoc = draw_central_stars_in_neighbooring_cubes(lines_origin, space_X, space_Y, space_Z, step_x, step_y); if (0) ad_hoc = 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 (0 && 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_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); if (0 && CUBE) draw_3_x_4_around_6_poles (lines_origin, s, side_size);
printf("DELTA = %d - %d = %d\nspace (%d x %d x %d) steps [ %d | %d | %d ]",\ int u = side_size * side_size * side_size / 2 * 6;
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); printf(" DELTA = %d - %d = %d\nspace (%d x %d x %d) steps [ %d | %d | %d ] ",\
s + u, ad_hoc, s + u - ad_hoc, space_X, space_Y, space_Z, step_x, step_y, step_z);
if (pref_test_diagonal) diagonal_test (space_X, space_Y, space_Z, step_x, step_y, step_z, lines_origin); 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"); if (1) calcul(lines_origin, side_size, s);
if (0) printf(" >>> prochain objectif : dessiner un voisinage de Moore 3D sphérique.\n");
return 0; return 0;
} }

View File

@ -550,11 +550,11 @@ GLuint arrows[] = {
static void get_model_data_and_user_preferences(){ static void get_model_data_and_user_preferences(){
space_X = 5; // 0 < space_X assert TODO space_X = 9; // 0 < space_X assert TODO
space_Y = 5; // 0 < space_Y assert TODO space_Y = 9; // 0 < space_Y assert TODO
space_Z = 5; // 0 < space_Z assert TODO space_Z = 9; // 0 < space_Z assert TODO
cubes_nb = space_X * space_Y * space_Z; cubes_nb = space_X * space_Y * space_Z;
pref_show_grid = 0; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc. pref_show_grid = 1; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc.
// xyz, 0, x, y, z, xy, xz, yz, xyz (repeat) // xyz, 0, x, y, z, xy, xz, yz, xyz (repeat)
int arrows_array_size = 0; int arrows_array_size = 0;
while (*(arrows + arrows_array_size) != un_nombre_qui_me_sert_à_mesurer_la_taille_du_tableau) while (*(arrows + arrows_array_size) != un_nombre_qui_me_sert_à_mesurer_la_taille_du_tableau)
@ -565,7 +565,9 @@ static void get_model_data_and_user_preferences(){
pref_central_stars_nb = cubes_nb; // cubes_nb = max = space_X * space_Y * space_Z pref_central_stars_nb = cubes_nb; // cubes_nb = max = space_X * space_Y * space_Z
pref_central_stars_nb = 1 + 6 + 24; pref_central_stars_nb = 1 + 6 + 24;
pref_central_stars_nb = 1 + 6; pref_central_stars_nb = 1 + 6;
pref_test_diagonal = 1; pref_central_stars_nb = 1;
pref_central_stars_nb = 0;
pref_test_diagonal = 0;
} }
@ -659,7 +661,7 @@ 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 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 // sinon, les arêtes de l'espace sont tracées par les grilles
buffer_lines_size += 6 * pref_central_stars_nb + 6; // test central stars buffer_lines_size += 6 * pref_central_stars_nb; // + 6; // test central stars
// if (pref_test_diagonal) buffer_lines_size += 2; // if (pref_test_diagonal) buffer_lines_size += 2;
// TESTS LINES BUFFER SIZE ON THE DIAGONAL [0 - max] // TESTS LINES BUFFER SIZE ON THE DIAGONAL [0 - max]