Salut!

Je suis entrain de faire une classe qui recherche les minimums et maximums en x, y et z d'un ensemble de vecteurs et qui les stocke dans un std::array à 2 dimension. (1ère dimension pour l'axe et seconde dimension pour les mins et maxs pour chaque axe)

Jusque là pas de soucis :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
 template <std::size_t N>
    static std::array<std::array<float, 3>,2> getExtends (const std::array<Vec3f, N>& verts) {
        float minX = 0;
        float maxX = 0;
        float minY = 0;
        float maxY = 0;
        float minZ = 0;
        float maxZ = 0;
        if (verts.size() > 0) {
            minX = verts[0].x;
            maxX = verts[0].y;
            minY = verts[0].x;
            maxY = verts[0].y;
            minZ = verts[0].z;
            maxZ = verts[0].z;
        }
        std::array<std::array<float, 3>, 2> store;
        for (unsigned int i(1); i < verts.size(); i++) {
 
 
                if (verts[i].x > maxX) {
                    maxX = verts[i].x;
                }
                if (verts[i].x < minX) {
                    minX = verts[i].x;
                }
                if (verts[i].y > maxY) {
                    maxY = verts[i].y;
                }
                if (verts[i].y < minY) {
                    minY = verts[i].y;
                }
                if (verts[i].z > maxZ) {
                    maxZ = verts[i].z;
                }
                if (verts[i].z < minZ) {
                    minZ = verts[i].z;
                }
 
 
        }
        store[0][0] = minX;
        store[0][1] = maxX;
        store[1][0] = minY;
        store[1][1] = maxY;
        store[2][0] = minZ;
        store[2][1] = maxZ;
        std::cout<<"min x : "<<store[0][0]<<" max x : "<<store[0][1]<<" minY = "<<store[1][0]<<" maxY : "<<store[1][1]<<" min Z : "<<store[2][0]<<" max Z : "<<store[2][1]<<std::endl;
        return store;
    }
J'ai une boîte de position 200, 200, 0 et de taille 120, 110, 0 et j'ai bien c'est valeurs-ci pour store[axe][borne] : (voici ce qu'il m'affiche)

minX : 200 maX : 320 minY : 200 maxY : 310 minZ : 0 maxZ : 0.

Le problème survient lorsque je récupère ce tableau dans une autre fonction, les valeurs ne sont alors plus bonne pour z :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
store = Computer::getExtends(points);
    std::cout<<"min x : "<<store[0][0]<<" max x : "<<store[0][1]<<" minY = "<<store[1][0]<<" maxY : "<<store[1][1]<<" min Z : "<<store[2][0]<<" max Z : "<<store[2][1]<<std::endl;
Voici ce qu'il m'afficher :

minX : 200 maX : 320 minY : 200 maxY : 310 minZ : 200 maxZ : 250.

Voila merci d'avance pour l'aide.