Optimized TestCollision Algorithm