Write the collision detection section.