[Math] Intersection between sphere and cylinder

3d

I have a sphere and a cylinder.

I have the center and the radius of each of them.

the sphere:

radius = $r_1$

center = $(x_1,y_1,z_1)$

the cylinder:

radius = $r_2$

height = $h_2$

center = $(x_2,y_2,z_2)$

how do I know if there is an intersection?

I read this one: http://en.wikipedia.org/wiki/Sphere%E2%80%93cylinder_intersection

but my center is not $(x_1,0,0)$ but $(x_1,y_1,z_1)$.

the radius in my sphere is 1, and the center point is $(x_1,y_1,z_1)$

the radius in my cylinder is 1, height is 10 and the center point is $(x_2,y_2,z_2)$.

I thought to convert my center point of $(x_1,y_1,z_1)$ into $(x_1,0,0)$ and then know if there is a intersection or not, according to the reference I linked..

any help appreciated!

Best Answer

You can translate the points to put the center of the sphere at the origin by making the center of the sphere $(0,0,0)$ and the center of the cylinder $(x_2-x_1,y_2-y_1,z_2-z_1)$ This is a translation of the space. If you want your results in the original coordinate system, just add $(x_1,y_1,z_1)$ to them.

Related Question