[FT] [computer] 3D math

6 posts ยท Sep 6 2000 to Sep 22 2000

From: Barclay, Tom <tomb@b...>

Date: Wed, 6 Sep 2000 15:37:46 -0400

Subject: [FT] [computer] 3D math

Hiya

I'm looking for a non-horrendous formula for calculating, given the
following facts,

- in 3 space
- a sphere we shall call S1 located at coorinates (x1,y1,z1) of radius
r1.
- a sphere we shall call S2 located at coorinates (x2,y2,z2) of radius
r2.
- a point we shall call P3 located at coordinates (x3,y3,z3).

A) Do r1 and r2 intersect one another? What formula will determine this?

<My guess: Take a line between the centre of S1 and S2 and determine if the
length of this segment exceeds the sum of the radii r1 and r2>.

B) What percentage of the volume of S2 is contained within S1? What formula
will determine this?

This one I won't guess at. I can't think of an elegant generic solution that
doesn't work by regions.

B) Is point P3 within sphere S1?

<My guess here is take the magnitude of the line between the centre of S1 and
P3 and if it is <= radius r1 then P3 is inside of S1>.

It strikes me these formula might be useful for determining moves in 3D vector
games on a computer. I'm looking at doing something in this line of thought
sometime. The math is vaguely disturbing though.

T.

From: Jon Davis <davisje@n...>

Date: Wed, 06 Sep 2000 21:33:28 -0400

Subject: Re: [FT] [computer] 3D math

> "Barclay, Tom" wrote:

If the line segment is less than the sum of the r1 and r2, then the spheres
intersect.

> B) What percentage of the volume of S2 is contained within S1? What

This is a harder problem, Tom. It is possible to compute the circle of
intersection
in 3-space between the two spheres.  Once that has been computed and its
location, you could compute the volume of the union by summing the portion of
each sphere cut by the plane of intersection. Just curious, why do you need
this computation?

> B) Is point P3 within sphere S1?

This is correct.

From: Nyrath the nearly wise <nyrath@c...>

Date: Wed, 06 Sep 2000 21:47:13 -0400

Subject: Re: [FT] [computer] 3D math

> "Barclay, Tom" wrote:

Yes, that's my take on it. Use the true distance formula.

        d = sqrt( (x1 - x2)^2 + (y1 - y2)^2 + (z1 - z2)^2 )
where: d = distance between the centers of the spheres sqrt(X) = square root
of X (x)^2 = square of x

S1 and S2 intersect each other if
        d < (r1 + r2)

From: Nyrath the nearly wise <nyrath@c...>

Date: Thu, 07 Sep 2000 19:31:16 -0400

Subject: Re: [FT] [computer] 3D math

> "Barclay, Tom" wrote:

From: Tony Francis <tony.francis@k...>

Date: Mon, 11 Sep 2000 10:33:49 +0100

Subject: Re: [FT] [computer] 3D math

> "Barclay, Tom" wrote:

> Hiya

Correct. Distance between the sphere centres (d) is equal to

d = sqrt ((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)

If this distance is less than (r1 + r2) then the spheres intersect.

If you want a faster version then don't perform the square root calculation on
d. Instead, square (r1 + r2) so that your comparison is

d^2 < (r1 + r2)^2

This is a trick I use a lot of the time so save unnecessary square root calls
(which are very computationally expensive).

> B) Is point P3 within sphere S1?

Correct again, but you can use the same trick as above by not finding the root
of the line between S1 and P3.

From: Jeff Miller <shadocat@p...>

Date: Fri, 22 Sep 2000 14:15:12 -0700

Subject: Re: [FT] [computer] 3D math

> Nyrath the nearly wise wrote:

> The answer was at

Cool site!

Thanks,