# Thread: Checking for a point inside a region of a spherical surface

1. ## Checking for a point inside a region of a spherical surface

Hi everybody,

I am working on a 3D Morphing algorithm.

I have a point X on lying on a unit sphere in the spherical coordinate system. I have three other points A,B, and C which are also on the unit sphere.

I need to find out whether X lies on the spherical surface enclosed by A,B, and C or not.

Can any one tell me how to do this?

2. Are these spheres centered at the Origin? Distance formula is sufficient.

If not, then find the center of the ABC sphere and it's the same problem.

Yes, the sphere is centered at the origin.

Can you please explain, how the distance formula maybe used to find this out?

4. In Rectangular Coordiantes, the point's address, (x,y,z) are easily used to calculate the distance - or in this case the square fo the distance will be fine - assuming the UNIT sphere is the only measure fo concern.

Distance From Origin = $\sqrt{x^{2}+y^{2}+z^{2}}$

If that's Greater than 1, it's outside.

I think your only real problem is likely to be precision. Is 1.00000000001 Outside or ON the Unit sphere? You WILL have to make up your mind.

5. Thanks for the reply. But, you didn't understand the problem at all. All four point lie on the same unit sphere center at the origin. So, ofcourse their distances from the origin will be 1 !

I want to decide whether X lies within the area that is bounded by A,B and C.

6. Well, it wasn't all that bad. I seem to have missed this section "which are also on the unit sphere". It is hard to judge the level of the question when no work is shown.

Find the three planes: OAB, OBC, OCA.

7. Thanks a lot. I get it now!

8. I'm new in sphere math world and i have the same problem.
Perhaps I'm wrong or perhaps I don't know how to implement the method of the planes you have decribed previously, but I think you are missing a little surface where you point may lye. If the region enclosed by points A B C is really a triangle (triangulated sphere) there will be no problem(I don't know how to calculate but I guess there will no information missing). But if points do not form a triangle but something like this:

B
A )
C

The plane OBC will leave outside the region |).

Correct me if i'm wrong

9. Yes egvega you are right. And this was the whole problem. Otherwise, finding a point exists within a triangle is not difficult.

The region bounded by the three points will NOT be (and cannot be) triangular on the sphere's surface! Still, the method described by TKHUNNY should work.

10. You're lucky if it's useful but i'm still trying to solve the problem. The case is that I do care about the region left outside the planes.
I found a way to know where the point is using sphere coordinates theta and phi but when the sphere rotate and the point is fixed, I don't know how to calculate the new region(i give numbers to them) enclosed by other 3 or 4 points where the point lyes. So I was looking for some general algorithm that i can apply no matter which rotation and how many of them I perform on the sphere.

11. Their won't be ANY region left outside.

12. If you have the point A on one pole and both,B and C, on, let's say, 45 degrees of latitude. The line conecting B and C will be an arc. So the plane OBC will leave some of the region outside. Check it with a ball, I have one on my hands right now

13. Yes. Now imagine a plane containing the points O,A,B (this plane is perpendicular to the curvature) ....now take another plane O,A,C and another plane O,B,C ..

Now we just need to find whether X lies 'IN BETWEEN' these three planes.

14. The three cutting planes must be distinct. If you get only 2 planes, B is on OAC, for example, the problem of containment makes no sense. A, B, and C must be NONcolinear - in a Great Circle sense.