Sign in to follow this  
juxie

sphere cylinder collision and distance

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 this post


Link to post
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 this post


Link to post
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 this post


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

Share this post


Link to post
Share on other sites
Quote:
Original post by oliii
It'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 this post


Link to post
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?

Please advise. Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by juxie
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?

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this