Cylinder-ray intersections
Algorithm with equations:
Step 1: Find solutions t1 and t2 of At2 + Bt + C = 0
if they exist. Mark as intersection candidates the one(s) that are nonnegative and for which (va, qi- p1) > 0 and (va, qi- p2) < 0, where qi=p+v ti
Step 2: Compute t3 and t4, the parameter values for which the ray intersects the upper and lower planes of the caps.If these intersections exists, mark as intersection candidates those that are nonegative and (q3 - p1)2 < r2 (respectively (q4 - p2)2 < r2 ).
In the set of candidates, pick the one with min. t.