ArticleslgStudy

computer science

Collision detection

Collision detection is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Collision detection rather than just read about it. In short: Collision detection is the computational problem of detecting an intersection of two or more objects in virtual space. More precisely, it deals with the questions of if, when, and where two or more objects intersect.

Collision detection — main illustration
Collision detection — illustration

Key takeaways

  • Collision detection belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Collision detection to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Collision detection from memory before moving on to harder problems.

Reference excerpt

Collision detection is the computational problem of detecting an intersection of two or more objects in virtual space. More precisely, it deals with the questions of if, when, and where two or more objects intersect. Collision detection is a classic problem of computational geometry with applications in computer graphics, physical simulation, video games, robotics (including autonomous driving), and computational physics. Collision detection algorithms can be divided into operating on 2D or 3D spatial objects.

Overview Collision detection is closely linked to calculating the distance between objects, as objects collide when the distance between them is less than or equal to zero. Negative distances indicate that one object has penetrated another. Performing collision detection requires more context than just the distance between the objects. Accurately identifying the points of contact on both objects' surfaces is also essential for computing a physically accurate collision response. The complexity of this task increases with the level of detail in the objects' representations: the more intricate the model, the greater the computational cost. Collision detection frequently involves dynamic objects, adding a temporal dimension to distance calculations. Instead of simply measuring distance between static objects, collision detection algorithms often aim to determine whether the objects' motion will bring them to a point in time when their distance is zero—an operation that adds significant computational overhead. In collision detection involving multiple objects, a naive approach would require detecting collisions for all pairwise combinations of objects. As the number of objects increases, the number of required comparisons grows rapidly: for n objects, n(n−1)/2 intersection tests are needed with a naive approach. This quadratic growth makes such an approach computationally expensive as n increases. Due to the complexity mentioned above, collision detection is a computationally intensive process. Nevertheless, it is essential for interactive applications like video games, robotics, and real-time physics engines. To manage these computational demands, extensive efforts have gone into optimizing collision detection algorithms. A commonly used approach towards accelerating the required computations is to divide the process into two phases: the broad phase and the narrow phase. The broad phase aims to answer the question of whether objects might collide, using a conservative but efficient approach to rule out pairs that clearly do not intersect, thus avoiding unnecessary calculations. Objects that cannot be definitively separated in the broad phase are passed to the narrow phase. Here, more precise algorithms determine whether these objects actually intersect. If they do, the narrow phase often calculates the exact time and location of the intersection.

Broad phase This phase aims at quickly finding objects or parts of objects for which it can be quickly determined that no further collision test is needed. A useful property of such approach is that it is output sensitive. In the context of collision detection this means that the time complexity of the collision detection is proportional to the number of objects that are close to each other. An early example of that is the I-COLLIDE where the number of required narrow phase collision tests was O(n+m) where n is the number of objects and m is the number of objects at close proximity. This is a significant improvement over the quadratic complexity of the naive approach.

Spatial partitioning Several approaches can be grouped under the spatial partitioning umbrella, which includes octrees (for 3D), quadtrees (for 2D), binary space partitioning (or BSP trees) and other, similar approaches. If one splits space into a number of simple cells, and if two objects can be shown not to be in the same cell, then they need not be checked for intersection. Dynamic scenes and deformable objects require updating the partitioning which can add overhead.

Bounding volume hierarchy A bounding volume hierarchy (BVH) is a tree structure in which each node is associated with a bounding volume enclosing the geometric primitives represented by its subtree. During collision detection, the tree is traversed from the root towards the leaves. If a node's bounding volume does not intersect the object or bounding volume being tested, its entire subtree can be discarded. Otherwise, the traversal continues to its child nodes. Hence, all the primitives associated with the discarded branches can be excluded without testing each primitive individually. To test two complex objects for collision, their BVHs can be traversed together, beginning with the root nodes. Pairs of branches whose bounding volumes do not intersect are discarded, while overlapping pairs are examined recursively. Exact intersection tests between the enclosed geometric primitives, often triangles and their components (vertices and edges), are required only for primitives contained in overlapping leaf nodes. The same approach can be used for self-collision detection. BVHs can organize the geometric primitives of a single object, the components of an articulated body, or multiple objects in a scene. They can be used with rigid and deformable objects, although a hierarchy over deformable geometry must be updated as the geometry changes. Because exact intersection tests are deferred to the leaves, BVHs can also accelerate collision detection between objects represented by different types of geometric primitives, provided suitable leaf-level intersection tests are available.

… excerpt ends here. Continue reading the full article.

Illustrations

Collision detection: Example of hitboxes of an attacking character in a fighting game. The green hitbox represents character collision zone, the red hitbox represents the attack's hit zone.
Example of hitboxes of an attacking character in a fighting game. The green hitbox represents character collision zone, the red hitbox represents the attack's hit zone.
Collision detection: Hitboxes
Hitboxes

Worked examples

Example 1 — a first encounter with Collision detection

Start with the simplest possible case. Write down what Collision detection claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Collision detection before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Collision detection ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Collision detection

In research
Collision detection appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Collision detection in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Collision detection is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computational geometry, Computer graphics, Computer physics engines, so understanding it makes those chapters shorter.
In everyday life
Look for Collision detection outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Collision detection” →

How to study Collision detection in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Collision detection means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Collision detection out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Collision detection in simple terms?

Collision detection is the computational problem of detecting an intersection of two or more objects in virtual space. More precisely, it deals with the questions of if, when, and where two or more objects intersect.

Why does Collision detection matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Collision detection?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Collision detection.

Tags

  • Computational geometry
  • Computer graphics
  • Computer physics engines
  • Robotics engineering
  • Video game development

Keep exploring