Bonjour,

j'ai produit un algorithme qui devrait me permettre de tourner un quadrilatère d'un certain angle par rapport a son centre.
Ça fonctionne avec un carré, un rectangle, un parallélogramme, un trapèze (si ce sont des formes symétriques) mais pas avec un quadrilatère quelconque dont voici l'exemple: http://img97.imageshack.us/i/quadnf.jpg/

Voici ce que j'ai fait (en c++), pouvez vous me dire ce qui ne va pas s'il vous plait?
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
 
        adj = base_bl.x;
        opp = base_bl.y;
        hyp = sqrt(adj*adj + opp*opp);
        angle = 360-acos(adj/hyp)*180/M_PI;
        x = hyp*cos((angleZ+angle)*M_PI/180) + centre.x;
        y = hyp*sin((angleZ+angle)*M_PI/180) + centre.y;
        bl.x = x;
        bl.y = y;
 
        adj = base_tl.x;
        opp = base_tl.y;
        hyp = sqrt(adj*adj + opp*opp);
        angle = acos(adj/hyp)*180/M_PI;
        x = hyp*cos((angleZ+angle)*M_PI/180) + centre.x;
        y = hyp*sin((angleZ+angle)*M_PI/180) + centre.y;
        tl.x = x;
        tl.y = y;
 
        adj = base_tr.x;
        opp = base_tr.y;
        hyp = sqrt(adj*adj + opp*opp);
        angle = acos(adj/hyp)*180/M_PI;
        x = hyp*cos((angleZ+angle)*M_PI/180) + centre.x;
        y = hyp*sin((angleZ+angle)*M_PI/180) + centre.y;
        tr.x = x;
        tr.y = y;
 
        adj = base_br.x;
        opp = base_br.y;
        hyp = sqrt(adj*adj + opp*opp);
        angle = 360-acos(adj/hyp)*180/M_PI;
        x = hyp*cos((angleZ+angle)*M_PI/180) + centre.x;
        y = hyp*sin((angleZ+angle)*M_PI/180) + centre.y;
        br.x = x;
        br.y = y;
descriptions:
base_bl : position originel bas gauche
base_tl : position originel haut gauche
base_tr : position originel haut droite
base_br : position originel bas droite
bl : position a afficher bas gauche
tl : position a afficher haut gauche
tr : position a afficher haut droite
br : position a afficher bas droite
angleZ : angle courant
angle : angle du point originel (base_..)
centre : position du point central par rapport auquel on fait une rotation

la valeur de 'angle' me parait bonne ainsi que la position de 'centre', ça clocherait d'après moi au niveau des calculs de x et y

Edit : c'était la position du centre qui n'était pas bonne, excusez moi et merci