I have a capsule defined by two points A and B and radius r. The ray is defined by equation: X = O + D*t. Now I need to get t for all (0-2) intersection points.
One possible solution would be to calculate intersection with spheres at A and B and intersections with cylinder. Then because capsule is convex I would just take minimum and maximum of all resulting t values.
But as wikipedia states, capsule intersection test should be even simpler than cylinder intersection test. Could somebody point me to an efficient capsule-ray intersection algorithm?
To test whether a capsule intersects a ray line just test distance between the line segment crossing points
AandBand the ray line. If the distance is smaller than radiusrthen there are two intersecting points, if is equal there is one touching point.To calculate intersection do as you described.