Are there any tutorials on it for DOS?
Printable View
Are there any tutorials on it for DOS?
Shouldn't make any difference what you're programming for, since it's all theory :D
You can surround objects with spheres and check that the distance of their centres isn't less than the sum of their radii (I think). If you want more accuracy you can have multiple spheres. From that it's possible to use bounding boxes as well.
http://www.cs.unc.edu/~geom/V_COLLIDE/
What if its a weird shaped item, and you want the collision to be on the edges of the item, not just NEAR it. It would look weird if a ball hit a paddle, and was still 1/2 an inch away and it bounced off...
Just something to think about!
This is why complex mesh objects are usually represented by a bounding box, and the object is decomposed into non-intersecting polygons to compare against (BSP trees).
First, check against the bounding box/sphere. If it's inside, check against each individual bounding box/sphere, until you eventually check against exact objects. This is for speed -- you can stick an entire tree into a bounding box and if you're over the other side of the world from the tree you're not checking against each individual leaf.
I think thats all a little much for a simple circle hitting a straight line.
Hehehe :D Just a tad ;)
There's a formula for the distance of a point from a line:
Distance of point (a,b,c) from line
ux + vy + wz + d = 0
is given by:
Code:|ua + vb + wc + d|
--------------------
sqrt(u^2 + v^2 + w^2)