0

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!

1 Answers1

0

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.

Ross Millikan
  • 374,822
  • thank you but if I will change the center of the sphere from (x1,y1,z1) into (x1,0,0) and then the center of the cylinder will become to (x2,y2-y1,z2-z1), how does it help me? the x point of the sphere is still x1, so if I will do: x+R<r before and after the translation, I will get the same.. can you show me with an example please? radius_sphere=1. center_sphere=(3,-5,9). radius_cylinder=1. center_cylinder=(-5,-7,2), height=10. please show me how to find if there is an intersection or isn't. thank you! – Maor Cohen May 16 '13 at 14:39
  • The article envisions $x_1 /ne x_2$, the difference is $a$. It presumes the cylinder is along $z$, so locations in that direction do not matter, and it aligns the offset between the center of the sphere and the axis of the cylinder to be along the $x$ axis. It also assumes the cylinder is infinitely long. For your case, $a=\sqrt{(3-(-5))^2+(-5 - (-7))^2}=\sqrt{68}$. As that is greater than the sum of the radii, there is no intersection. – Ross Millikan May 16 '13 at 15:18