# [Numpy-discussion] Re: Newbie: Matrix form of segment-sphere intersection?

Jim Carroll jimpy at oublic.org
Fri Mar 24 08:48:03 CST 2006

```> On Thu, 23 Mar 2006, (UTC) Jim Carroll apparently wrote:
> > Where can I find applicable tutorials or recipies?
>
> Don't know the lit, but noticed this:
> http://www.olympus.net/personal/7seas/contain.html
>

Interesting... but it doesn't show the how the points are formatted in the
matricies, or how a more complicated algebraic function would be done...

The sphere intersection 3 step algorithm defines some values up front, then
finds the discriminant, then uses the discriminant to caluclate the intersection.

I'm wondering if I'd be crazy if I coded the algorithm in a C ufunc:
for a table where each row has  x1, y1, z1, x2, y2, z2, radius   if my ufunc
would return a table that's got just three columns: x3, y3, z3 representing the
sphere intersection.  (asuming the input is translated so the sphere is at the
origin.)

Does anyone do this kind of things with ufuncs?  Am I on the right track, but
there's an easier way to do it?  Or, is there a geometric math library that does
this kind of thing?  (I found one a year ago, but can't remember if it's this
sophisticated.)

Thanks,
-Jim

```