Advertisement

cylinder-triangle intersection test

Started by August 24, 2002 10:26 PM
6 comments, last by billybob 22 years, 5 months ago
i need to make a function that returns true if a vector[3] triangle and a cylidner(radius, height) are intersecting. the cylinder is always vertical, the caps always point up-down to fit a character model best. it doesn''t need to be blistering fast, since the engine will rarley actually do per poly collison, but obviously it needs some good speed. how would i go about this?
Why not test each of the three vertices to see if they are inside the cylinder? If any are there is an intersection.

Jack
Advertisement
It's not that easy. There could be an intersection even if there were no vertices inside the cylinder. AFAIK, there is no single test to check if there is an intersection. You have to do multiple tests. Off the top of my head:

1. Make the triangle-vertex inside cylinder test
2. Intersect the triangle edges with the infinite cylinder. You should get two intersection points; check if they are inside the cylinder
3. Intersect the axis of the cylinder with the plane of the triangle. Check if the intersection point is inside the triangle and inside the cylinder.
4. Intersect the top and bottom circles of the cylinder with the plane of the triangle. Check if the intersection points are inside the triangle.

There is probably a shorter way, but I'd have to make a Google search to find it, and if you're posting here, it's because you've already done one and there weren't any relevant pages, haven't you?

If you have problems with some of these tests, post again. They aren't very hard (although I've never tried #2 and #4)

EDIT: Let me rephrase that: If you have problems with some of these tests, please, try Google, then try the forum archives. If you don't find your answer, post again.

Cédric

[edited by - cedricl on August 24, 2002 12:06:02 AM]

[edited by - cedricl on August 24, 2002 12:09:06 AM]
i did a google search, i found this INCREDIBLE resource: www.magic-software/Intersection3d.html it has a TON of object object intersection tests, including oriented bounding boxes, but it stops just before cylinder-triangle i found some others but they weren''t cylinder triangle, most were particle system tests. i think i can make something out of what cedricl said, and i''m probably going to want to vertex in cylinder tests first since that is pretty likeley. i know i can do #1, and #3, MAYBE #2, but no idea for #4.
Cool, you did search. I should have waited 3 seconds before doing that EDIT

Actually, #4 is easier than I thought. Intersect the plane of the triangle with the plane of the circle. You'll get a line. From then on, you should work in 2D on the plane of the circle. Find the two intersection points between the line and the circle. This is quite easy. Finally, check if these two points are inside the triangle.

Cédric

EDIT: You could also intersect the line with the sphere of the circle.

I just read your original post; have you looked at capsules? They are easier to handle than cylinders, and I think that there is an article on them on Gamedev.

[edited by - cedricl on August 24, 2002 12:24:32 AM]
ok, i can do everything you said except intersect a circle and plane. if i get that, then i can do #4.
Advertisement
Theres an excellent paper called ERIT - A Collection of Efficient and Reliable Intersection Tests (actually it''s a report of the ERIT package), do a search, it contains algos for cylinder/tri, sphere/tri, torus/tri etc. and goes through them well (it''s a bit mathematical but well, that''s the field ).
arbitrary-line--arbitrary-cylinder collision is great fun... not. There is a line-cylinder test in graphics gems 4 which did the trick for me.
See this link
http://thorkildsen.no/faqsys/gems/gems4.zip
on this page
http://thorkildsen.no/faqsys/gems.html

This topic is closed to new replies.

Advertisement