🔒 Locked
3d circle collision
Advertisement
Original Post
I want to do collision detection between a circle and a aa box in 3d. I though I could just do a check between the circle and each face of the box. I was wondering is there a better way to do it?
First find a vector that goes from the center of the box to the center of the sphere (that''s a 3d circle). Then find the point where the vector intersects with a face of the box. Then check if the distance between the point and the center of the sphere is smaller then the radius of the sphere. If it is smaller you have a collision, greater is no collision, equal is... something that almost never happens.
But the most difficult part is finding the intersection point of the vector and a face of the box.
I haven''t tried any of this, it''s just what I came up with
But the most difficult part is finding the intersection point of the vector and a face of the box.
I haven''t tried any of this, it''s just what I came up with
I'm terribly sorry for what I'm about to do, this reply is totally useless, so just ignore it.
A 3D circle? Surely that's a torus or a sphere of some kind? Circle is by definition a 2D entity and can never exist in a 3D world. Circle-box collision detection is 2D, and should be sphere to cube collision detection in 3D, should it not?
Again, I apologise for being such a moron, I just woke up in a stupid mood
[edited by - Bad Maniac on January 8, 2004 7:12:31 AM]
A 3D circle? Surely that's a torus or a sphere of some kind? Circle is by definition a 2D entity and can never exist in a 3D world. Circle-box collision detection is 2D, and should be sphere to cube collision detection in 3D, should it not?
Again, I apologise for being such a moron, I just woke up in a stupid mood
[edited by - Bad Maniac on January 8, 2004 7:12:31 AM]
quote:
Original post by Bad Maniac
A 3D circle? Surely that''s a torus or a sphere of some kind? Circle is by definition a 2D entity and can never exist in a 3D world.
Why not? Cut out a nice round circle from a piece of paper. Voila, a 2D circle in a 3D(4D) world. (Take this with a grain of salt please)
quote:
Circle-box collision detection is 2D, and should be sphere to cube collision detection in 3D, should it not?
Yes, it should. but he''s not completely wrong.
quote:
Unfortunately, geometers and topologists adopt incompatible conventions for the meaning of "n-sphere," with geometers referring to the number of coordinates in the underlying space and topologists referring to the dimension of the surface itself (Coxeter 1973, p. 125). As a result, geometers call the circumference of the usual sphere the 2-sphere, while topologists refer to it as the 1-sphere and denote it
You see, even scientist can''t figure it out. A circle is not per definition 2D.
Circle definition:
quote:
A circle is the set of points equidistant from a given point O.
That definition doesn''t say anything about the number of dimensions. A sphere also qualifies for this definition of a circle.
quote:I''d actually get a very thin 3 diomensional disc. Not a 2D circle. *keeps on ranting throught the night*
Original post by Rule
Cut out a nice round circle from a piece of paper. Voila, a 2D circle in a 3D(4D) world.
quote:
Original post by Bad Maniac
I''d actually get a very thin 3 diomensional disc. Not a 2D circle.
That''s what the "(Take this with a grain of salt please)" was about
But I don''t think it is impossible to have a n-1 dimensional object in a n dimensional space as long as n > 1.
quote:
*keeps on ranting throught the night*
It''s not night where I am
Oh yeah sorry a sphere it was late when i posted. There''s only three faces of the box that the player can collide with at any one time and since it''s an aa box i can easy find what those faces are. then i''ll just do what Rule surgested. thanks.
I haven''t done any of this myself, but Rule''s suggestion doesn''t sound like it would work. It would be far too easy for the sphere to still intersect the corners of the box, even when his check says that there is no intersection. It won''t intersect along the vector which you picked, but another part of the sphere might intersect somewhere else on the box. Checking each face of the box is the safest way I can think of.
In reality isn''t 3D math just 2D ... I mean a given point in space to another (line segment) but on a curve is in 3D space with all 3 being used.. However if you look at the math really is 2D ... it lies on a plane. That plane is all you need .... The rest of the stuff is just 2D.
??? Am I wrong?
But the solution is
As the first person answered.
??? Am I wrong?
But the solution is
As the first person answered.
quote:
Original post by Agony
It won''t intersect along the vector which you picked, but another part of the sphere might intersect somewhere else on the box.
Yes, I also thought of that problem. But I don''t think it will happen with sphere-box CD. I will be a problem when you apply the same method to do box-box CD which is very difficult.
I have the sourcecode of a physics engine with CD lying around so I will check to see how they do it...
Ok found the code. This is the commentary above the dCollideSphereBox function:
// this is easy. get the sphere center `p'' relative to the box, and then clip
// that to the boundary of the box (call that point `q''). if q is on the
// boundary of the box and |p-q| is <= sphere radius, they touch.
// if q is inside the box, the sphere is inside the box, so set a contact
// normal to push the sphere to the closest box face.
Jippie, I was right!
*feel good about himself*
If you are interested in the function you can download ODE. Look in the src directory for the file collision_std.cpp, line 1081.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement
