# Intersecting three rays and a sphere of known radius

So I actually solved this problem using an iterative solver, but it annoys me because as far as I can tell it should be possible to do it directly.

I have three known 3D "rays" that all start at the origin, and are represented as three unit vectors $a$, $b$, and $c.$

I know that these three rays all touch the surface sphere of known radius $R$ (without intersecting the interior of the sphere). So the task is to find the center position of the sphere $p$.

For this to have a solution the three rays all point more or less in the same direction which I know they do by construction in my case (in fact, in my specific case I happen to know that the $z$ component is $<0$ for $a, b$ and $c$). I also know that the sphere is "in front" of all thee rays (and does not contain the origin.. i.e. $p.p > R^2$)

I thought this would be easy to solve, just set up the distance from the point to each ray and set it to be equal to $R$, then manipulate and solve for $p$, but alas I could not manage to isolate any sensible expression for $p$. I then tried both Maple and Mathematica and was unable to solve it there either (in fact, Mathematica just hangs indefinitely). This leads me to believe I'm not properly stating this problem.

As I mentioned, I was able to solve this iteratively (gauss newton) but it just kind of bugs me so I was hoping maybe someone could have a stab and show me how to do it, maybe I'll pick up some tricks for next time.

• I know how to solve it in theory, but I can't seem to actually solve it in practice :( The problem is that a,b,c are not points, they're rays - which means that each of y our A, B and C above include p in the expression (e.g. A is p projected onto a), so it just gets super messy and I can't even set it up in a way that mathematica can solve so I must be missing some key trick that makes it possible to solve this. Apr 21, 2016 at 20:16
• sorry I didn't get what you know. you only know $R$ and that three given rays intersect the sphere ? in that case there are of course many solutions. hence I thought you knew the intersection points Apr 21, 2016 at 20:23
• I know three specific rays that touch the surface of the sphere, and R. I don't know the center point of the sphere. I think the reasoning below about the planes seems promising so I'm going to have a go with that. Apr 21, 2016 at 20:25
• (and a ray is a starting point and a direction, not a starting point and a ending point) Apr 21, 2016 at 20:28
• I don't know the three points, I just know the rays. I.e. a*s touches the sphere, but I know a, not s (knowing s requires knowing p, but I don't know p either). There's clearly enough information to work it out, I just can't figure out how to manipulate things to get p to fall out. Apr 21, 2016 at 20:29

Given three unit vectors $a$, $b$, and $c$ and the radius $R$ of a sphere tangent to all three of the rays in the directions of $a$, $b$, and $c$ from the origin.

We desire to find the unknown center $p$ of that sphere.

There is a plane $\pi_1$ through the origin and through $p$ such that the unit vectors $a$ and $b$ are mirror images of each other through $\pi_1$.

In fact the plane $\pi_1$ is just the plane through the origin perpendicular to $b - a$.

Likewise, if $\pi_2$ is the plane through the origin perpendicular to $c - a$, then $a$ and $c$ are mirror images of each other through $\pi_2$ and $\pi_2$ passes through $p$.

The planes $\pi_1$ and $\pi_2$ intersect in a line that passes through the origin and through $p$. By finding the sine of the angle between this line and one of the vectors $a$, $b$, or $c$, and using the fact that the origin, one of the points of tangency, and $p$ must form a right triangle, you can find the distance from the origin to $p$, and since you know the direction from the origin you can find the point exactly.

For the actual calculation, you can use some vector arithmetic, for example a vector along the line from the origin to $p$ is $v = \pm (b - a) \times (c - a)$, and you can use $\lVert v \times a \rVert = \lVert v \rVert \lVert a \rVert \sin \theta_{va}$ to find the sine of the angle $\theta_{va}$ between $v$ and $a$.

• Thanks, this seems like a solid plan! I'll give this a go! Apr 21, 2016 at 20:26
• @user1952009 And nothing else. I've edited the answer to list the given information explicitly. Apr 21, 2016 at 20:29
• hence you can't locate the sphere since there are many solutions Apr 21, 2016 at 20:32
• @user1952009 I'm not seeing your "many solutions". There are multiple spheres of radius $R$ tangent to the three lines through the origin parallel to $a$, $b$, and $c$, but "rays" means only half the line is valid, and that eliminates all but one possibility. Apr 21, 2016 at 20:42
• FWIW, this method worked perfectly! Apr 21, 2016 at 20:45