WIP: Un algorithme qui calcule l'adresse mémoire d'un point (i,j,k) de l'espace. OK
This commit is contained in:
parent
7211f7315d
commit
85ac5c78a2
125
a resoudre
125
a resoudre
|
@ -1,125 +0,0 @@
|
|||
step_z = 1, step_y = space_Z, step_x = space_Z * space_Y
|
||||
|
||||
x.y.z v(i,j,k) delta v = i * step_x + j * step_y + k * step_z
|
||||
--------------------------------------------------------------------
|
||||
1 0 5 = 2 + 3 -76 --100 = 24
|
||||
3 13 66 = 5 + 61 -52 - -76 = 24
|
||||
5 62 149 = 66 + 83 -28 - -52 = 24
|
||||
7 171 236 = 149 + 87 -4 - -28 = 24
|
||||
9 364 303 = 236 + 67 20 - -4 = 24
|
||||
11 665 236 = 303 + 23 23 / ? = ? 44 - 20 = 24
|
||||
13 1098 281 = 326 - 45 45 / 23 = 1,956521739 45 - -23 = 68 68 - 44 = 24
|
||||
15 1687 144 = 281 - 137 137 / ? = ? 137 - 45 = 92 92 - 68 = 24
|
||||
17 2456 -109 = 144 - 253 253 / 137 = 1,846715328 253 - 137 = 116 116 - 92 = 24
|
||||
19 3429 -502 = -109 - 393 393 / 253 = 1,553359684 393 - 253 = 140 140 - 116 = 24
|
||||
21 4630 -1059 = -502 - 557 557 / 393 = 1,417302799 557 - 393 = 164 164 - 140 = 24
|
||||
23 6083 -1804 = -1059 - 745 745 / 557 = 1,337522442 745 - 557 = 188 188 - 164 = 24
|
||||
25 7812 -2761 = -1804 - 957 957 / 745 = 1,284563758 957 - 745 = 212 212 - 188 = 24
|
||||
27 9841 -3954 = -2761 - 1193 1193 / 957 = 1,246603971 1193 - 957 = 236 236 - 212 = 24
|
||||
29 12194 -5407 = -3954 - 1453 1453 / 1193 = 1,217937972 1453 - 1193 = 260 260 - 236 = 24
|
||||
31 14895 -7144 = -5407 - 1737 1737 / 1453 = 1,195457674 1737 - 1453 = 284 284 - 260 = 24
|
||||
33 17968 -9189 = -7144 - 2045 2045 / 1737 = 1,177317214 2045 - 1737 = 308 308 - 284 = 24
|
||||
35 21437 2377 - 2045 = 332 332 - 308 = 24
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--------------------------------------------
|
||||
3 * 3 * 3
|
||||
step_z * space_Z
|
||||
+ step_y * space_Y
|
||||
+ step_x * space_X
|
||||
+ (i + 0) * step_x * 6
|
||||
+ (j + 0) * step_y * 6
|
||||
+ (k + 0) * step_z * 6
|
||||
+ space_X * space_Y * space_Z / 2
|
||||
+
|
||||
12
|
||||
=
|
||||
space_X * space_Y * space_Z * 6 / 2
|
||||
- 2
|
||||
3 * 3 * 3 rayon = 0,00 i,j,k = 0, 0, 0 coeff = 39 center = 13 u = 13 delta = 12
|
||||
-----------------------------------------
|
||||
|
||||
9 * 3 * 11 space_X = 9; space_Y = 3; space_Z
|
||||
= 11;
|
||||
int center = space_X * space_Y * space_Z / 2;
|
||||
int step_z = 1, step_y = space_Z, step_x = space_Z * space_Y;
|
||||
int coeff = step_z * space_Z + step_y * space_Y + step_x * space_X;
|
||||
for ... for ... for ... rayon = 0,00 i,j,k = 0, 0, 0
|
||||
int u = (i - space_X / 2) * step_x + (j - space_Y / 2) * step_y + (k - space_Z / 2) * step_z;
|
||||
u = (i + 0) * step_x + (j + 0) * step_y + (k - 0) * step_z;
|
||||
if (1) printf("%d*%d*%d rayon = %4.2f i,j,k = %2d,%2d,%2d \n",\
|
||||
space_X, space_Y, space_Z, rayon, space_X / 2 - i, space_Y / 2 - j, space_Z / 2 - k);
|
||||
draw_a_central_star(lines_origin, coeff + center + u * 6 + 12 - 3);
|
||||
9 * 3 * 11 rayon = 0,00 i,j,k = 0, 0, 0 coeff = 341 center = 148 u = 148 delta = -9
|
||||
-----------------------------------------------------------------------------------------------
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = 1, 1, 0 coeff = 155 center = 62 u = 32 delta = -1
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = 1, 0, 1 coeff = 155 center = 62 u = 36 delta = -1
|
||||
5 * 5 * 5 rayon = 1,00 i,j,k = 1, 0, 0 coeff = 155 center = 62 u = 37 delta = -1
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = 1, 0,-1 coeff = 155 center = 62 u = 38 delta = -1
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = 1,-1, 0 coeff = 155 center = 62 u = 42 delta = -1
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = 0, 1, 1 coeff = 155 center = 62 u = 56 delta = -1
|
||||
5 * 5 * 5 rayon = 1,00 i,j,k = 0, 1, 0 coeff = 155 center = 62 u = 57 delta = -1
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = 0, 1,-1 coeff = 155 center = 62 u = 58 delta = -1
|
||||
5 * 5 * 5 rayon = 1,00 i,j,k = 0, 0, 1 coeff = 155 center = 62 u = 61 delta = -1
|
||||
5 * 5 * 5 rayon = 0,00 i,j,k = 0, 0, 0 coeff = 155 center = 62 u = 62 delta = -1 <
|
||||
5 * 5 * 5 rayon = 1,00 i,j,k = 0, 0,-1 coeff = 155 center = 62 u = 63 delta = -1
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = 0,-1, 1 coeff = 155 center = 62 u = 66 delta = -1
|
||||
5 * 5 * 5 rayon = 1,00 i,j,k = 0,-1, 0 coeff = 155 center = 62 u = 67 delta = -1
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = 0,-1,-1 coeff = 155 center = 62 u = 68 delta = -1
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = -1, 1, 0 coeff = 155 center = 62 u = 82 delta = -1
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = -1, 0, 1 coeff = 155 center = 62 u = 86 delta = -1
|
||||
5 * 5 * 5 rayon = 1,00 i,j,k = -1, 0, 0 coeff = 155 center = 62 u = 87 delta = -1
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = -1, 0,-1 coeff = 155 center = 62 u = 88 delta = -1
|
||||
5 * 5 * 5 rayon = 1,41 i,j,k = -1,-1, 0 coeff = 155 center = 62 u = 92 delta = -1
|
||||
-----------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
d8065ec 2023-08-20 14:31 +0200 Jean Sirmai o WIP: une approche par step_x, _y, _z <> commit avant de repartir
|
||||
d8065ecf5f73276276353a60786ba4ae3e40c61f - commit 5 of 202
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
// SI JE CALCULE LA POSITION D'UNE ÉTOILE CENTRALE EN FONCTION DE i, j, k
|
||||
// step_z = 1, step_y = space_Z + 1, step_x = (space_Z + 1) * (space_Y + 1)
|
||||
// s = step_z * space_Z + step_y * space_Y + step_x * space_X + 1
|
||||
// s + cubes_nb * 3 - 3
|
||||
// à (i * step_x + j * step_y + k * step_z) * 6,
|
||||
// JE DOIS RAJOUTER LA VALEUR DELTA
|
||||
|
||||
/* side step_x step_y step_z n delta */
|
||||
/* ---------------------------------------------------------- */
|
||||
/* 3 16 4 1 149 3 */
|
||||
/* 5 36 6 1 588 10 */
|
||||
/* 7 64 8 1 1538 53 */
|
||||
/* 9 100 10 1 3184 156 */
|
||||
/* 11 144 12 1 5375 343 */
|
||||
/* 13 196 14 1 9332 638 */
|
||||
/* 15 256 16 1 14218 1065 */
|
||||
/* 17 324 18 1 20568 1648 */
|
||||
/* 19 400 20 1 28574 2411 */
|
||||
/* 21 484 22 1 38428 3378 */
|
||||
|
||||
|
||||
/*
|
||||
s = step_z * space_Z + step_y * space_Y + step_x * space_X + 1
|
||||
draw_a_central_star (lines_origin, s + cubes_nb * 3 - 3);
|
||||
|
||||
static int draw_a_central_star(GLuint *lines_origin, int 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;
|
||||
}
|
||||
*/
|
Binary file not shown.
After Width: | Height: | Size: 235 KiB |
20
resolu
20
resolu
|
@ -1,17 +1,18 @@
|
|||
delta = 2 + 3 + 61 + 83 + 87 + 67 + 23
|
||||
- 45 - 137 - 253 - 393 - 557 - 745
|
||||
- 957 - 1193 - 1453 - 1737 - 2045 - 2377
|
||||
= - 11566
|
||||
- 957 - 1193 - 1453 - 1737 - 2045
|
||||
- 2377 - 2733 - 3113 - 3517 ---
|
||||
|
||||
------------------------------------------
|
||||
côté dérivée_1 dérivée_2
|
||||
c (1) (d1) (d2)
|
||||
------------------------------------------
|
||||
1 . -76 --100 = 24
|
||||
3 . -52 - -76 = 24
|
||||
5 . -28 - -52 = 24
|
||||
7 . -4 - -28 = 24
|
||||
9 . 20 - -4 = 24
|
||||
11 -23 . 44 - 20 = 24
|
||||
1 -4 - 72 = -76 -76 --100 = 24
|
||||
3 -56 - -4 = -52 -52 - -76 = 24
|
||||
5 -84 - -56 = -28 -28 - -52 = 24
|
||||
7 -88 - -84 = -4 -4 - -28 = 24
|
||||
9 -68 - -88 = 20 20 - -4 = 24
|
||||
11 -23 - -68 = 44 44 - 20 = 24
|
||||
13 45 - -23 = 68 68 - 44 = 24
|
||||
15 137 - 45 = 92 92 - 68 = 24
|
||||
17 253 - 137 = 116 116 - 92 = 24
|
||||
|
@ -24,6 +25,9 @@ côté dérivée_1 dérivée_2
|
|||
31 1737 - 1453 = 284 284 - 260 = 24
|
||||
33 2045 - 1737 = 308 308 - 284 = 24
|
||||
35 2377 - 2045 = 332 332 - 308 = 24
|
||||
37 2733 - 2377 = 356 356 - 332 = 24
|
||||
39 3113 - 2733 = 380 380 - 356 = 24
|
||||
41 3517 - 3113 = 404 404 - 380 = 24
|
||||
|
||||
Pour calculer l'adresse mémoire des trois lignes
|
||||
qui dessinnent l'étoile située au centre d'un cube
|
||||
|
|
|
@ -435,7 +435,8 @@ static void experimental_1(GLuint *lines_origin, int space_X, int space_Y, int
|
|||
int step_z = 1, step_y = space_Z, step_x = space_Z * space_Y;
|
||||
int coeff = step_z * space_Z + step_y * space_Y + step_x * space_X;
|
||||
int u = 0, v = 0,
|
||||
delta = 3 + 2 + 61 + 83 + 87 + 67 + 23 - 45 - 137 - 253 - 393 - 557 - 745 - 957 - 1193 - 1453 - 1737 - 2045 - 2377;
|
||||
delta = 3 + 2 + 61 + 83 + 87 + 67 + 23 - 45 - 137 - 253 - 393 - 557 - 745
|
||||
- 957 - 1193 - 1453 - 1737 - 2045 - 2377 - 2733 - 3113 - 3517;
|
||||
delta -= 0;
|
||||
|
||||
if (1) printf("space_XYZ (%d*%d*%d) steps_xyz (%d,%d,%d) coeff = %d = step_z * space_Z + step_y * space_Y + step_x * space_X\n",\
|
||||
|
@ -474,15 +475,6 @@ space_X, space_Y, space_Z, cubes_nb, (b-a)/18, rayon, coeff, center, delta);
|
|||
bool draw_some_arrows (GLuint *lines_origin, int s, int stx, int sty,
|
||||
GLuint *arrows, int arrows_nb) {return 1;}
|
||||
|
||||
static void calcul(GLuint *lines_origin, int cote, int coeff){
|
||||
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, coeff + centre);
|
||||
}
|
||||
|
||||
bool compute_space(int space_X, int space_Y, int space_Z,
|
||||
GLuint *arrows, int model_arrows_nb,
|
||||
int pref_show_grid, int pref_central_stars_nb,
|
||||
|
@ -512,15 +504,51 @@ bool compute_space(int space_X, int space_Y, int space_Z,
|
|||
if (0) draw_EW_ZA_SN_in_a_cubic_space (lines_origin, coeff, space_X, space_Y, space_Z);
|
||||
if (0) draw_3_x_4_around_6_poles (lines_origin, coeff, side_size);
|
||||
|
||||
if (0) printf(" DELTA = %d - %d = %d space (%d x %d x %d) steps [ %d | %d | %d ] ",\
|
||||
coeff + u, ad_hoc, coeff + 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 (0) calcul(lines_origin, side_size, coeff);
|
||||
if (0) printf(" >>> prochain objectif : dessiner un voisinage de Moore 3D sphérique.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
delta = 2 + 3 + 61 + 83 + 87 + 67 + 23 - 45 - 137 - 253 - 393 - 557 - 745
|
||||
- 957 - 1193 - 1453 - 1737 - 2045 - 2377 - 2733 - 3113 - 3517 ---
|
||||
|
||||
------------------------------------------
|
||||
côté dérivée_1 dérivée_2
|
||||
c (1) (d1) (d2)
|
||||
------------------------------------------
|
||||
1 -4 - 72 = -76 -76 --100 = 24
|
||||
3 -56 - -4 = -52 -52 - -76 = 24
|
||||
5 -84 - -56 = -28 -28 - -52 = 24
|
||||
7 -88 - -84 = -4 -4 - -28 = 24
|
||||
9 -68 - -88 = 20 20 - -4 = 24
|
||||
11 -23 - -68 = 44 44 - 20 = 24
|
||||
13 45 - -23 = 68 68 - 44 = 24
|
||||
15 137 - 45 = 92 92 - 68 = 24
|
||||
17 253 - 137 = 116 116 - 92 = 24
|
||||
19 393 - 253 = 140 140 - 116 = 24
|
||||
21 557 - 393 = 164 164 - 140 = 24
|
||||
23 745 - 557 = 188 188 - 164 = 24
|
||||
25 957 - 745 = 212 212 - 188 = 24
|
||||
27 1193 - 957 = 236 236 - 212 = 24
|
||||
29 1453 - 1193 = 260 260 - 236 = 24
|
||||
31 1737 - 1453 = 284 284 - 260 = 24
|
||||
33 2045 - 1737 = 308 308 - 284 = 24
|
||||
35 2377 - 2045 = 332 332 - 308 = 24
|
||||
37 2733 - 2377 = 356 356 - 332 = 24
|
||||
39 3113 - 2733 = 380 380 - 356 = 24
|
||||
41 3517 - 3113 = 404 404 - 380 = 24 ... etc.
|
||||
|
||||
Pour calculer l'adresse mémoire des trois lignes
|
||||
qui dessinnent l'étoile située au centre d'un cube
|
||||
de côté 'c' il faut faire la somme des quatre termes :
|
||||
- coeff_1 = step_z * space_Z + step_y * space_Y + step_x * space_X
|
||||
- coeff_2 = (i * step_x + j * step_y + k * step_z) * 6
|
||||
- center = space_X * space_Y * space_Z / 2 et
|
||||
- delta = sigma (de 1 à c) des termes de la colonne 1
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -634,45 +662,4 @@ bool compute_space(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)
|
||||
|
||||
/* #define D 0 */
|
||||
/* static int experimental_1_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; */
|
||||
/* } */
|
||||
|
||||
|
||||
|
|
|
@ -552,9 +552,9 @@ GLuint arrows[] = {
|
|||
|
||||
static void get_model_data_and_user_preferences(){
|
||||
|
||||
space_X = 35; // 0 < space_X assert TODO
|
||||
space_Y = 35; // 0 < space_Y assert TODO
|
||||
space_Z = 35; // 0 < space_Z assert TODO
|
||||
space_X = 41; // 0 < space_X assert TODO
|
||||
space_Y = 41; // 0 < space_Y assert TODO
|
||||
space_Z = 41; // 0 < space_Z assert TODO
|
||||
cubes_nb = space_X * space_Y * space_Z;
|
||||
pref_show_grid = 1; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc.
|
||||
// xyz, 0, x, y, z, xy, xz, yz, xyz (repeat)
|
||||
|
|
Loading…
Reference in New Issue