ABSTRACT
Collision detection between moving objects is an open question which raises major problems concerning its
algorithmic complexity. In this paper we present a polygon collision detection algorithm which uses polygon
decomposition through triangle coverings and polygon influence areas (implemented by signs of barycentric
coordinates). By using influence areas and the temporal and spatial coherence property, the amount of time
needed to detect a collision between objects is reduced. By means of these techniques, a valid representation for
any kind of polygon is obtained, whether concave or convex, manifold or non-manifold, with or without holes, as
well as a collision detection algorithm for this type of figures. This detection algorithm has been compared with
the well-known PIVOT2D [Hof01] one and better results have been achieved in most situations. This
improvement together with its possible extension to 3D makes it an attractive method because pre-processing of
the polygons is no longer necessary. Besides, since this method uses sign operations, it proves to be a simple,
more efficient and robust method.
Keywords
Animation, Barycentric Coordinates, Coherence, Collision Detection, Triangle Cover.
5
Corollary : Likewise, we define point P as outside the
4 triangle ABC, if and only if :
6 P3
s<0t<0u<0
P0 3
2
P2 Geometric Interpretation of Barycentric
1 P1 Coordinates of a Point with Regard to a
Triangle
Position P0 P1 P2 P3
Order 123456 123456 123456 123456 If barycentric coordinates of a point P in relation to
Sign
s coord. mask
+-++++
110111
+-++++
110011
+-++++
110011
+-++++
111111 S,T,U are s,t,u, then a point with sign(s)=+1 will be
t coord. mask
u coord. mask
11-000
11----
10--01
1----0
------ 100100
0--100
placed on the same side as S, with respect to the
state OUT OUT EQUAL IN infinite line that goes through U and T. If sign(s)=-1,
Point in position P1 is in the same zone as in P2. If the point it will be on the opposite side; if sign(s)=0, it will be
changes from P2 to P3, it changes zones.
on the line (Figure 2).
Figure 1. Sample operation of 2D point-polygon U
t<0
collision detection algorithm. A covering of the
s>=0
polygon by triangles has been carried out and t>=0 s<0
shows a division on zones. S u>=0
100.00
100.00 90.00
90.00 80.00
80.00 70.00
70.00 60.00
60.00 50.00 seconds
50.00 seconds 40.00
40.00 30.00
30.00 20.00
512
512
20.00 10.00
10.00 128 0.00
128 0.00
10
32
51
24
10
25
32
51
24
12
vertices of
2
25
64
8
12
vertices of
32
moving polygon
64
8
16
32
b)
16
Figure 12. Times obtained in tests with a) the new algorithm and b) PIVOT2D. X and Z axes show the
number of vertices of the static and moving polygons respectively.
This is due to the size of the influence areas (which speed of the algorithm based on the size of the
depend on the radius of the bounding circumference influence areas and to obtain the times of effective
of the moving polygon) and to the size of the edges of calculation of the edges involved in the collision.
the static polygon. The greater the number of edges
of the static polygon, the smaller the edges, because 8. ACKNOWLEDGEMENTS
the figure is enclosed within the same volume. This work has been partially granted by the Ministry
Therefore, both the size of the different influence of Science and Technology of Spain and the
areas and the degree of spatial coherence diminish, European Union by means of the ERDF funds, under
because a point moves from one area to others with the research project TIC2001-2099-C03-03
greater frequency, thereby reducing the effectiveness 9. REFERENCES
of the algorithm.
[Bad90] Badouel, F. An efficient Ray-Polygon
The PIVOT2D behaviour becomes worse in the case intersection. Graphics Gems. Academic Press,
of static polygons with few vertices (8-32 vertices) 390-393, 1990
and of polygons in movement with many vertices [Fei95] Feito, F; Torres, J.C.; et al; Orientation,
(128-512 vertices), whereas the new algorithm Simplicity and Inclusion Test for Planar
achieves quite low times. In all the remaining Polygons. Computer & Graphics, 19:4, 1995
performed tests (different types of polygons and [Fei97]Feito, F; Torres, J.C. Boundary representation
linear trajectory), the results are similar or better to of polyhedral heterogeneous solids in the context
the obtained with contour polygons and circular of a graphic object algebra. The Visual Computer,
trajectory. 13, pp. 64-77, Springer-Velag, 1997
[Fei98] Feito, F.R.; Segura, R.J.; Torres, J.C.
7. CONCLUSIONS AND FUTURE Representing Polyhedral Solids by Simplicial
WORK Coverings. Set-Theoretic Solid Modelling,
We have obtained a 2D polygon-polygon collision Techniques and Applications, CSG98
detection algorithm with better times than those Information Geometers, 203-219, 1998
provided by the PIVOT2D library in most situations. [Hai94] Haines, E. Point in Polygon Strategies.
This algorithm is simple, more efficient and robust. Graphics Gems IV. Academic Press, 1994.
Besides, it is suitable for any type of polygon, convex [Hof01] Hoff III, Kenneth E.; Zaferakis, A.; Lin M.;
or non-convex, manifold or non-manifold, with or Manocha, D.; Fast and Simple 2D Geometric
without holes, and, above all, it may be extended to Proximity Queries Using Graphics Hardware.
3D, which makes it especially attractive. Symposium on Interactive 3D Graphics (I3D),
It uses a triangles covering of the polygons as pre- 2001. http://www.cs.unc.edu/~geom/PIVOT/
processing. This covering is made in a linear time [Hof89] Hoffmann, C. Geometric and Solid
based on the number of vertices, no type of complex Modelling. An Introduction. Morgan Kaufmann
data structure being necessary. The algorithm also Publishers, 1989.
uses the geometric and temporal coherence. Besides, [Jim01] Jimnez, P.; Thomas, F.; Torras, C. 3D
once the collision is detected, we can obtain the edges collision detection: a survey. Computer &
taking part in it, almost at the same time. One final Graphics 25 (2001) 269-285
advantage is that it allows specifying a distance [Jim02a] Jimnez, J.J.; Segura, R.J.; Feito, F.R.
between objects. Tutorial sobre Deteccin de Colisiones en
Informtica Grfica. Novatica, N 157. May-June
The algorithm is being improved as far as its
2002, pp 55-58
implementation is concerned. These improvements
[Jim02b] Jimnez, J.J., Segura, R.J., Feito, F.R..
can offer us still better times than those reflected in
Algorithms for Point-Polygon Collision Detection
this study. Some of these improvements would be: the
in 2D. 1st Ibero-American Symposium on
efficient implementation of the operations between
Computer Graphics, Guimaraes-Portugal, pp.
bit masks; the use of graphical hardware speeding up
253-261, 2002
the operations; the use of techniques of space
[Lar00]Larsen, E.; Gottschalk, S.; Lin, M.; Manocha,
subdivision, invariants with rigid transformations; the
D.; Fast distance queries with rectangular swept
use of the geometric coherence to calculate the edges
sphere volumes. IEEE International Conference
that cross influence areas, so that it is not necessary to
on Robotics and Automation, 2000
re-calculate them in the following movement; the
[Las96] Laszlo, M. Computational Geometry and
extension of these techniques to several moving
Computer Graphics in C++. Prentice Hall, 1996.
objects; and, finally, the use of bounding volumes
[Lin98] Lin, M; Gottschalk, S. Collision Detection
hierarchies at different levels of detail. Extension to
between Geometric Models: A Survey. IMA
3D is the most important work to be developed. It is
Conference on Mathematics of Surfaces, 1998.
also necessary to make a mathematical study of the