POV-Ray : Newsgroups : povray.newusers : Coordinates of a point knowing 3 points and 3 distances : Re: Coordinates of a point knowing 3 points and 3 distances Server Time
28 Sep 2024 07:42:24 EDT (-0400)
  Re: Coordinates of a point knowing 3 points and 3 distances  
From: Luc H 
Date: 1 Apr 2012 08:40:01
Message: <web.4f784c4c790e9ffba2302ac00@news.povray.org>
This is how I did it for 3 points.

#declare P1=<0,0,0>;
#declare R1=4;

#declare P2=<0,0,0>;
#declare R2=2;

#declare P3=<0,0,0>;
#declare R3=2;

#declare P4=<0,0,0>;
#declare R4=2;

#declare D12=R1+R2; // distance from P2 to P1
#declare D13=R1+R3; // distance from P3 to P2
#declare D23=R2+R3; // distance from P3 to P2

#declare D14=R1+R4; // distance from P4 to P1
#declare D24=R2+R4; // distance from P4 to P2
#declare D34=R3+R4; // distance ftom P4 to P3

// Coordinates of P2 are easy :
#declare P2=P1 + <D12,0,0>;

// Coordinates of P3 :
#declare alpha=acos((D13*D13 + D12*D12 - D23*D23)/(2*D13*D12));
#declare P3 = P1 + <D13*cos(alpha), D13*sin(alpha), 0>;

// Just playing with D12, D13 and D23 I have 3 spheres with radius R1, R2, R3
that touch each others, and on the XZ plan

// That's where it become tough : find the P4 coordinates knowing D14, D24 and
D34
#declare alx=acos((D14*D14+D12*D12-D14*D14)/(2*D14*D12));
#declare aly=acos((D14*D14+D13*D13-D34*D34)/(2*D14*D13));

// I thought P4 coordinates would be :
#declare P4x = D14*sin(alx);
#declare P4y = D14*cos(aly);
#declare P4z = D14*sin(aly);
// ... but seems to be buggy.
// I should have 4 spheres touching each other, but P4 is not at the good place.


sphere { P1, R1
         texture { pigment{ color rgbf <1,0,0,0.5> }
                   finish { phong 0.1 }
                 }
       }

sphere { P2, R2
         texture { pigment{ color rgbf <0,0,1,0.5> } // rgb< 1, 0.0, 0.0>}
                   finish { phong 0.1 }
                 }
       }

sphere { P3, R3
         texture { pigment{ color rgbf <0,1,0,0.5> } // rgb< 1, 0.0, 0.0>}
                   finish { phong 0.1 }
                 }
       }

sphere { P4, R4
         texture { pigment{ color rgbf <1,1,0,0.5> } // rgb< 1, 0.0, 0.0>}
                   finish { phong 0.1 }
                 }
       }


Post a reply to this message

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