POV-Ray : Newsgroups : povray.general : Intersection of three spheres? : Re: Intersection of three spheres? Server Time
8 Aug 2024 20:27:08 EDT (-0400)
  Re: Intersection of three spheres?  
From: Greg M  Johnson
Date: 20 Oct 2000 21:16:58
Message: <39f0ee8a@news.povray.org>
I tried exactly this approach and got multiple divide by zero messages.

#declare x1=0;
#declare y1=0;
#declare z1=0;
#declare r1=1.3;          //really this sphere plus radius to touch it!

#declare x2=2;
#declare y2=0;
#declare z2=0;
#declare r2=1.3;

#declare x3=0.5;
#declare y3=0;
#declare z3=.5;
#declare r3=1.3;

#declare a32=-2*x3+2*x2;
#declare b32=-2*y3+2*y2;
#declare c32=-2*z3+2*z2;
#declare d32=r3^2-r2^2+x3^2-x2^2+y3^2-y2^2+z3^2-z2^2 ;

#declare a31=-2*x3+2*x1;
#declare b31=-2*y3+2*y1;
#declare c31=-2*z3+2*z1;
#declare d31=r3^2-r1^2+x3^2-x1^2+y3^2-y1^2+z3^2-z1^2 ;

#declare a21=-2*x2+2*x1;
#declare b21=-2*y2+2*y1;
#declare c21=-2*z2+2*z1;
#declare d21=r2^2-r1^2+x2^2-x1^2+y2^2-y1^2+z2^2-z1^2 ;

#declare
z4=((d21*a31-d31*a21)/(a21*b31-b21*a21)+(d32*a21=d21*a32)/(a21*b32-a32*b21))

                /

((c21*a32-c32*a21)/(a21*b32-a32*b21)+(a21*c32-c21*a31)/(a21*b31-b21*a31));

#declare
y4=z4*(c21*a32-c32*a21)/(a21*b32-a32*b21)+(d21*a32-d32*a21)/(a21*b32-a32*b21);

#declare x4=-y4*b21/a21-z4*c21/a21-d21/a21;




Micha Riser wrote:

> For the three spheres you get the 3 functions:
>
> I:   ( x - x0 )^2 + ( y - y0 )^2 + ( z - z0 )^2 - r0 ^2
> II:  ( x - x1 )^2 + ( y - y1 )^2 + ( z - z1 )^2 - r1 ^2
> III: ( x - x2 )^2 + ( y - y2 )^2 + ( z - z2 )^2 - r2 ^2
>
> with <xn,yn,zn> as the middle points and rn the radii
>
> When you set I == II and I == III and simplify this you get two
> equations of the following form:
>
> A*x+B*y+C*z==D
>
> (with A,B,C,D as constants)
>
> These are the equations for the planes in which the cutting circles lie
> in. Now you just need to calcualte the cutting line of these two planes.
> And finally cut one of your inital sphere with this line... then you get
> your desired points.
>
> I didn't care about the specal cases here (0/1/infitely many points)
> because you said you were only interested in the 2 points-case.
>
> I don't know if there is a more easy way but it should work this way.
> You can also get a general formula from this.
>
> Hope this helps
> - Micha


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.