Skip to main content
GameDev.net gamedev.net
🔒 Locked

Collision Detection

Started by Zorodius Jun 15, 2002 at 12:42 AM 1 replies 200+ views
Original Post
Zorodius
Zorodius
I''m just starting to add weapons and enemies and all that neat stuff to my game. So I''d like to start off with a workable collision detection system. I just need to know if a ray intersects a sphere. I don''t care what the specific point of intersection is. From reading about it, it sounds like the following method can be used to determine if the ray intersects the sphere, reasonably quickly, without being too complicated: 1- Find if the ray''s origin is outside the sphere. 2- Find the closest approach, tca, of the ray with the sphere If the ray is outside and points away from the sphere, the ray must miss the sphere. 3- Find the squared distance from the closest approach, t2hc, to the sphere surface. If the value is negative the ray misses 4- Using tca & t2hc calculate the time, t, of intersection with the sphere t = tca - sqrt(t2hc), origin outside sphere t = tca + sqrt(t2hc), origin inside sphere So, my questions are: 1) Does this method sound like it would work? 2) Is it correct to assume that it can be determined if "the ray points away from the sphere" by seeing if the angle between the ray''s direction and a "perfect" vector towards the sphere (sphere''s center - ray''s origin) is greater than 180 degrees? 3) This is going to sound silly, but... What is the "closest approach", and how is it calculated? Thanks in advance for any answers - I appreciate it!
You don't need to vote for the "lesser of two evils"! Learn about Instant Runoff Voting, the simple cure for a broken democracy!
_DarkWIng_
_DarkWIng_
find paper called "Generic Collision Detection for Games Using Ellipsoids" by Paul Nettle. It''s a realy nice paper on Cd and it has function for ray&sphere intersection. Another good paper on this is "Collision detection & Response" by Telemachos.

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Zorodius
Zorodius
Thanks! I''ll look for those papers when I get the chance.
However, does anyone have an answer to my questions? At least number 3 (what is "closest approach" and how is it calculated)?
You don't need to vote for the "lesser of two evils"! Learn about Instant Runoff Voting, the simple cure for a broken democracy!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.