# Arbitrary vector intersect sphere

1. Feb 2, 2012

### mj878

It says Sphere in the title but I actually meant Cylinder (Ive been working on it a few hours and brains gone numb). The problem is to do with an algorithm for a game im making in openGL. I need the points of intersect of a vector (O+Dt) and a cylinder with radius r, direction A and point on the cylinder core B (we can assume infinite height).

So far I had the following

$| (O + D . t1) - (A + B . t2 ) | = r$

and

$B . ( (O + D . t1) - (A + B . t2 ) ) = 0$

and then tried to solve it, but the equation became quite long and I likely made an error along the way.

Does anyone have an easier way of solving it, or has anyone solved it before?