WIP: simplifications avant restructuration. Is OK

This commit is contained in:
Jean Sirmai 2023-07-21 09:09:23 +02:00
parent 90e2c8d346
commit 19d9e258cc
Signed by: jean
GPG Key ID: FB3115C340E057E3
1 changed files with 41 additions and 38 deletions

View File

@ -293,9 +293,9 @@ static int compute_arrow_2D(int size_x,
#define CORRC 1.3
#define P 0
static bool compute_space_3D (int size_x,
int size_y,
int size_z,
static bool compute_space_3D (int x,
int y,
int z,
int pref_mark_unit_space,
int pref_style_lines_planes,
@ -306,62 +306,62 @@ static bool compute_space_3D (int size_x,
GLubyte *line_origin,
GLubyte *plan_origin)
{
int maximum = 0, c = 0; // TODO max = math.max(max, size_x);
for (c = 0; c <= size_x; c++) if (c > maximum) maximum = c;
for (c = 0; c <= size_y; c++) if (c > maximum) maximum = c;
for (c = 0; c <= size_z; c++) if (c > maximum) maximum = c;
int maximum = 0, c = 0; // TODO max = math.max(max, x);
for (c = 0; c < x; c++) if (c > maximum) maximum = c;
for (c = 0; c < y; c++) if (c > maximum) maximum = c;
for (c = 0; c < z; c++) if (c > maximum) maximum = c;
float i, j, k, x, y, z, max = maximum * CORRC;
float i, j, k, vx, vy, vz, max = maximum * CORRC;
printf("max(%d,%d,%d) = %d; size_x / max = %6.3f; size_y / max = %6.3f; size_z / max = %6.3f\n",\
size_x, size_y, size_z, maximum, size_x / max, size_y / max, size_z / max);
x - 1, (y - 1) - 1, z - 1, maximum, (x - 1) / max, (y - 1) / max, (z - 1) / max);
for (i = 0; i <= size_x; i++){
for (j = 0; j <= size_y; j++){
for (k = 0; k <= size_z; k++){
for (i = 0; i < x; i++){
for (j = 0; j < y; j++){
for (k = 0; k < z; k++){
x = (2 * i / size_x - 1) * (size_x / max);
y = (2 * j / size_y - 1) * (size_y / max);
z = (2 * k / size_z - 1) * (size_z / max);
vx = (2 * i / (x - 1) - 1) * ((x - 1) / max);
vy = (2 * j / (y - 1) - 1) * ((y - 1) / max);
vz = (2 * k / (z - 1) - 1) * ((z - 1) / max);
*(vertex_origin + vertex_ndx + 0) = x / 2;
*(vertex_origin + vertex_ndx + 1) = y;
*(vertex_origin + vertex_ndx + 2) = z;
*(vertex_origin + vertex_ndx + 0) = vx / 2;
*(vertex_origin + vertex_ndx + 1) = vy;
*(vertex_origin + vertex_ndx + 2) = vz;
vertex_ndx += 3; // if (V) printf(" => vertex_ndx = %3d\n", vertex_ndx);
*(color_origin + colors_ndx + 0) = x;
*(color_origin + colors_ndx + 1) = 3 * y / 2;
*(color_origin + colors_ndx + 2) = z;
*(color_origin + colors_ndx + 0) = vx;
*(color_origin + colors_ndx + 1) = 3 * vy / 2;
*(color_origin + colors_ndx + 2) = vz;
colors_ndx += 3; // if (C) printf(" => colors_ndx = %3d\n", colors_ndx);
if (P) printf("(%1.0f*%1.0f*%1.0f)<>[%6.3f %6.3f %6.3f] ", i, j, k, x, y, z);
if (P) printf("(%1.0f*%1.0f*%1.0f)<>[%6.3f %6.3f %6.3f] ", i, j, k, vx, vy, vz);
}
if (P) printf(" ");
}
if (P) printf("\n");
};
for (int u = 0; u < size_y + 1; u ++){
for (int w = 0; w < size_z + 1; w ++){
*(line_origin + lines_ndx) = w + (size_z + 1) * u; lines_ndx += 1;
*(line_origin + lines_ndx) = (size_x + 1) * (size_y + 1) * (size_z + 1)
- (size_y + 1) * (size_z + 1) + w + (size_z + 1) * u; lines_ndx += 1;
for (int u = 0; u < y; u ++){
for (int w = 0; w < z; w ++){
*(line_origin + lines_ndx) = w + z * u; lines_ndx += 1;
*(line_origin + lines_ndx) = x * y * z
- y * z + w + z * u; lines_ndx += 1;
}
}
for (int u = 0; u <= size_y; u ++){
for (int w = 0; w < size_x + 1; w ++){
*(line_origin + lines_ndx) = (size_z + 1) * (size_y + 1) * w + (size_z + 1) * u; lines_ndx += 1;
*(line_origin + lines_ndx) = (size_z + 1) * (size_y + 1) * w + size_z + (size_z + 1) * u; lines_ndx += 1;
for (int u = 0; u < y; u ++){
for (int w = 0; w < x; w ++){
*(line_origin + lines_ndx) = z * y * w + z * u; lines_ndx += 1;
*(line_origin + lines_ndx) = z * y * w + z - 1 + z * u; lines_ndx += 1;
}
}
for (int u = 0; u <= size_x; u ++){
for (int w = 0; w < size_y; w ++){
*(line_origin + lines_ndx) = (size_z + 1) * (size_y + 1) * u + w; lines_ndx += 1;
*(line_origin + lines_ndx) = (size_z + 1) * (size_y + 1) * u + (size_z + 1) * size_y + w; lines_ndx += 1;
for (int u = 0; u < x; u ++){
for (int w = 0; w < y - 1; w ++){
*(line_origin + lines_ndx) = z * y * u + w; lines_ndx += 1;
*(line_origin + lines_ndx) = z * y * u + z * (y - 1) + w; lines_ndx += 1;
}
}
@ -509,6 +509,7 @@ static bool compute_space_3D (int size_x,
return 1;
}
static void show_user_choices(int model_size_x,
int model_size_y,
int model_size_z,
@ -538,6 +539,8 @@ static void show_user_choices(int model_size_x,
i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2), *(arrows + i * 5 + 3), *(arrows + i * 5 + 4));
}
bool compute_space_and_arrows(int model_size_x,
int model_size_y,
int model_size_z,
@ -566,9 +569,9 @@ bool compute_space_and_arrows(int model_size_x,
pref_style_lines_planes,
pref_style_mix_colors);
compute_space_3D (model_size_x,
model_size_y,
model_size_z,
compute_space_3D (model_size_x + 1,
model_size_y + 1,
model_size_z + 1,
pref_mark_unit_space,
pref_style_lines_planes,