I am looking for an efficient way of finding the intersection of a line with a cylinder. Several answers are suggested on this site and other places, however I found this answer the most efficient one. The only challenge I am facing is that the given question and its answer only apply to a case where the line originates from the cylinder axis. Is there any similar approach that can be generalized to lines starting and ending at any arbitrary position?
To be specific, I am looking for finding intersection of any arbitrary line with a cylinder where the cylinder axis is assumed to lie on one the axes (say Z-axis). The given cylinder doesn't have caps and therefore, the line may or may not intersect with the cylinder. If it does intersect, it may have one or two intersection(s) of course.


