# sphere cylinder collision and distance

This topic is 3936 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, What is the way to find the way to check if sphere is colliding with cylinder and then find how much the sphere should move along the movement vector before it reaches the cylinder surface? Thanks.

##### Share on other sites
Collision between an infinite cylinder of radius R and a sphere of radius Q is the same as that of the cylinder's median axis and the sphere centered on the original sphere and with radius R + Q. Thus, your problem can be solved as a ray-sphere intersection.

##### Share on other sites
Might be worth considering if you can use a sphere to capsule test (rather than sphere to cylinder). Then it would be a sphere to swept-sphere test.

##### Share on other sites
It's like a sphere-edge test, with an added radius on the edge, and checking against caps.

##### Share on other sites
Quote:
 Original post by oliiiIt's like a sphere-edge test, with an added radius on the edge, and checking against caps.

Oliii,

I have looked at your sweptsphere.zip samples.
It's very good and I have tried the Ray-AABB intersection and got it working.
But I am wondering how I can get the normal for the ray-AABB intersection using the slab method you did?

##### Share on other sites
Ok, i managed to get the collision normal for the ray-AABB using the slab method.

Another question for intersection of ray and any objects.
It may be slightly stupid to ask but just would like to put ease of mind.
If I managed to find the point of collision, is it actually okay to add a distance of 0.00001f * collisionNormal to the position so that the object is slightly off the surface of sphere?

##### Share on other sites
Quote:
 Original post by juxieOk, i managed to get the collision normal for the ray-AABB using the slab method.Another question for intersection of ray and any objects.It may be slightly stupid to ask but just would like to put ease of mind.If I managed to find the point of collision, is it actually okay to add a distance of 0.00001f * collisionNormal to the position so that the object is slightly off the surface of sphere?Please advise. Thanks.

I use bisection method to find the position without collision, with the good precision, and one with good precision with collision to have the contact manifold (whom i take the mean to have just one contact (this in the triangle-triangle intersection))

manonoc

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 12
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633723
• Total Posts
3013545
×