Bonjour tout le monde !
Je cherche une solution (la plus simple possible) pour savoir si 2 polygones convexes se touchent.
J'ai plusieurs hypothèses :
- Les polygones sont plans
- Un des polygones est dans un plan fixe en X, Y ou Z (horizontal ou vertical), mais ça ne devrait pas changer grand chose
- L'autre polygone n'est pas dans un plan fixe
- Ils sont convexes comme déjà mentionné
J'ai rencontré pas mal de méthodes, certaines pour du 2D, dont Separating Axis Theorem. J'ai donc cherché SAT pour du 3D et je suis tombé sur http://www.gamedev.net/topic/606539-...nvex-polygons/ cette discussion.
Est-ce que la méthode proposée par "taz0010" vous paraît pertinente ? Elle me semble pas mal, mais j'ai un doute et je ne trouve pas d'autre trace sur le web.
Merci d'avance,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 1. loop through each line segment that makes up Polygon A, checking whether each segment intersects with Polygon B's plane. If no segments intersect, break early and return Polygon B's plane as the separating plane. 2. loop through each line segment that makes up Polygon B, checking whether each segment intersects with Polygon A's plane. If no segments intersect, break early and return Polygon A's plane as the separating plane. 3. If both 1 and 2 did find intersections, see if the two line segments overlap. If they do overlap, there is an intersection. Splitting one of the polygons down the line of intersection will resolve the intersection. 4. If the segments did not overlap, then the polygons do not intersect. To construct the separating plane, we use the cross product of the normals of the two planes as the normal, and for the location we select a point (let's say half way between) the two line segments (though any point within this region should be valid).
Luigi
Partager