I am trying to write a few collision detection methods for a game and I was wondering if there was an easy equation to check coliision for a cylinder than checking every single vertex of the mesh. I understand checking spheres and boxes, but is there an easy equation for checking cylinders?
It depends what you're colliding the cylinder against. However most poeple tend to use capsules (think of a swept sphere or the classic cartoon pill) since they're much quicker. This basically just comes down to checking if any point on your object is closer than the capsules radius to the capsules line segment. As for cylinders first you'll have to project the other object's extents onto the cylinder's axis. If they all lie outside the cylinders length then no collision. If they all lie inside the cylinders length then you can use the capsule test since the cylidners flat caps won't be involved. However if some lie in and some lie out then you'll have to start checking line segments of the object against the circle which is the cylinders cap. Sorry if this isn't too clear but its not easy to explain in a limited space and without pictures. Bottom line though is if you can get away with capsules, do so. The other trick some people use to model cylinders is to use several boxes layered ontop of each other but rotated around the 'cylinders' axis at equal intervals. The more boxes you use the better the representation but the more costly it is to collide.
There's also an article in one of the GPG books about cylinder frustum culling that I imagine has good cylinder/plane code in it. But basically, unless you're doing something fairly simple, like an FPS where you're always aligned to the same axis, cylinders are kind of a pain for collision detection. Spheres, capsules, OBBs and ellipsoids (except with each other) are all easier.
Thanks for all the input. The reason for knowing cylinder was basically that I was planning to write a simple physics engine that could accurately roll a barrel down a hill. It sounds like capsules would be the best way to go about doing this so I will look into that more and see what I can find. Thanks again.