Update
This commit is contained in:
parent
9005259ff3
commit
df80221a15
29 changed files with 1864 additions and 1808 deletions
|
@ -20,7 +20,7 @@ In many cases it is also important to correctly detect the **order of collisions
|
|||
|
||||
Up until now we have considered **analytical collision detection**, i.e. the mathematically precise solution that we get by solving an equation (such as in the case of two spheres and comparing their distance with the sum of their radii) -- this is based on [analytic geometry](analytic_geometry.md) and the fact that geometry can be handled by algebraic methods. This method is a cool approach to solving collisions if you can manage it, it is precise and often even fast, however -- as mentioned -- in many cases too hard and tedious. Therefore we may also consider a [good enough](good_enough.md) approximate solutions using **[numerical](numerical.md) methods** instead, i.e. the "less elegant", more [bruteforce](bruteforce.md) kinds of methods that do things such as iterative checking of many points in space to see if there is a collision happening there or not. This will be less precise and may be slower for simpler shapes (though for very complex shapes it may be faster), however the algorithm will be simpler AND, very significantly, it can kind of work for general cases, i.e. you may just have one algorithm that will be able to check all kinds of shapes. Even numerical methods may be written well and optimizing them may result in a very good algorithm.
|
||||
|
||||
Numerical algorithms can be made in many ways; consider for example the following: you can divide your whole space into a grid ("Minecraft" style) and then for every shape you have to simply write a function that checks if a single point lies in the shape or not (this is much simpler than checking collisions between complex shapes) -- now to check if a collision is happening you may just check all the grid points in space and if you find a grid square whose center point lies in two shapes at once, you detected a collision (which you may then even check with greater precision by subdividing the cell itself and checking all the subcells etc.). This can be optimized for example with things like [octrees](octree.md) that will allow you to skip big empty areas and not waste time on checking them. Or you don't have to have a global grid but you may just iterate over shapes and for each such shape check some *N* points that lie inside it (which you just somehow generate, e.g. by [interpolating](interpolation.md) between its vertices or something), again checking if any of these points lies in another shape. Or you may be trying something like iteratively stepping towards where an intersection of two shapes should lies (like e.g. [Newton's method](newtons_method.md)). There are many possibilities here.
|
||||
Numerical algorithms can be made in many ways; consider for example the following: you can divide your whole space into a grid ("Minecraft" style) and then for every shape you have to simply write a function that checks if a single point lies in the shape or not (this is much simpler than checking collisions between complex shapes, also you'll only need *N* such algorithms for *N* shape types) -- now to check if a collision is happening you may just check all the grid points in space and if you find a grid square whose center point lies in two shapes at once, you detected a collision (which you may then even check with greater precision by subdividing the cell itself and checking all the subcells etc.). This can be optimized for example with things like [octrees](octree.md) that will allow you to skip big empty areas and not waste time on checking them. Or you don't have to have a global grid but you may just iterate over shapes and for each such shape check some *N* points that lie inside it (which you just somehow generate, e.g. by [interpolating](interpolation.md) between its vertices or something), again checking if any of these points lies in another shape. Or you may be trying something like iteratively stepping towards where an intersection of two shapes should lies (like e.g. [Newton's method](newtons_method.md)). There are many possibilities here.
|
||||
|
||||
**[Signed distance functions](sdf.md)** can potentially be used to implement collision detection. { That's how I did it in [tinyphysicsengine](tinyphysicsengine.md). ~drummyfish }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue