## Homework #2: Collision Detection Between Rigid Bodies

October 30, 2007

### A. Implementation

Our code is based on the framework from last homework and the collision detection package SWIFT++. The source code and Windows XP binary can be downloaded from ../code/HW2.zip.

### B. Analysis

Number of Objects. Suppose we have n objects in the scene. Each object is tested against n - 1 objects for collision, therefore the time complexity is roughly O(n2). Fig. 1 is the resulting plot. The blue crosses are data points, and the green curve is a fitted second order polynomial. The plot roughly obeys the O(n2) expectation.

Complexity of Objects. We tested on several polygonal models of the sphere, and found that the performance is related to the number of polygons. However, the number of polygons does not reflect the number of exact polygon-to-polygon intersection tests due to the use of bounding box hierarchy. Therefore the relation of complexity of model and performance is weaker. Fig. 2 is our experimental result. As the number of polygons grows ten times, the change in performance is relatively small.

Size of Objects. When the size of objects grows, the probability of collision also increases, therefore the simulation time should also increase. Intuitively, the probability of collision should be related to total surface area of all objects, and therefore the time should be O(d2), where d is the diameter of objects. Fig. 3 is the plot of simulation time and the diameter of objects, along with a fitted second order polynomial.

### C. Varying Parameters

If the size of objects is constant, we can subdivide the domain into equally sized cells and can assure that an object can only collide with objects in neighboring cells, if the cell is not smaller than the object. When moving objects, the grids are updated, and then each object is only tested with those in neighboring cells. If the cost of collision query is high, this scheme can save a lot of time. However, in our simple scene, we did not see any improvement with uniform grid. This may due to the fact that the cost of collision is relatively small compared to the cost of updating grid cells.