Article Preview
Buy Now
FEATURE
BONK -- Ouch!
Spherical Collision Detection and Response in 3D
Issue: 2.4 (March/April 2004)
Author: Lars Jensen
Author Bio: Lars Jensen started programming before many of you started breathing...and he'll still be at it after you're all dust! Bwahahahaaa-a-a-a...
Article Description: No description available.
Article Length (in bytes): 39,455
Starting Page Number: 23
Article Number: 2412
Resource File(s):
2412.zip Updated: 2013-03-11 19:07:57
Related Web Link(s):
http://www.gamedev.net/reference/list.asp?categoryid=45#99
http://www.gamedev.net/reference/articles/article1234.asp
http://www.wheatchex.com/projects/collisions
http://www.quesa.org/
http://mathworld.wolfram.com/QuadraticEquation.html
http://mathworld.wolfram.com/VietasFormulas.html
Excerpt of article text...
Collision detection (figuring out whether objects come in contact with one another) and its sibling, collision response (figuring out what to do about it) are rich, complex topics in computer simulations of the physical world. There are many such simulations: computer-aided design tools, movie special effects, even screen savers... and, of course, games.
In Issue 2.2 (Oct/Nov 2003) of
REALbasic Developer , Thomas Reed's articleCollision Detection and Response showed how to simulate a round ball bouncing off a flat surface. In this article, we'll cover a related topic: how to simulate collisions among spheres moving in a 3D environment, and how to make them react in a fairly realistic way. Even if your objects aren't actually spherical, the collision detection technique code can serve as a quick initial test, after which you can investigate potential collisions in more detail.We'll look at a few fast, general routines to handle this situation, along with their derivations, and a general framework in which to make them run. You can skip the math and physics if you like, but you'll need to know vector arithmetic to use the code.
We'll also look at building a special-purpose tool that makes it quick and easy to test these routines, plus any refinements you might come up with on your own. The completed tool is part of the download for this article, and represents a professional approach to isolating and testing important parts of your system that might be impractical to test in the "deployed environment" (that is, the game you're writing). It sounds very gritty and industrial, but you'll see that REALbasic's simplicity makes it inviting and -- dare I say it? -- even a little fun.
Organization: Frames and Subframes
Before we dive head-first into equations, let's consider our task: simulate a bunch of spherical bodies bouncing off each other, like a game of billiards in three dimensions. Such simulations often work by repeatedly calling a "frame driver" -- a routine that figures out what has happened to everything in the simulation since the last time it was called.
...End of Excerpt. Please purchase the magazine to read the full article.