|
![](/i/fill.gif) |
"Mark M. Wilson" wrote:
> I have a couple of questions, actually. The second is dependent on the
> first.
> 1) It's been a LOOONNNNGGGGGG time since high school geometry, but it
> seems to me it should be possible to scribe a circle given any three
> (coplanar) points. Am I right?
>
> 2) if the premise in #1 is correct, does anyone know of any macros for
> Povray that will calculate the coordinates of the center of such a
> circle?
>
> TIA,
> Mark M. Wilson
Here is a macro I created using the Law of Sines.
#macro Center(a,b,c)
#local d = (a+b)/2;
#local e = (b+c)/2;
#local v0 = vnormalize(vcross((b-c),(b-a)));
#local v1 = vnormalize(vcross(d-b,v0));
#local v2 = vnormalize(vcross(v0,e-b));
#local a1 = (acos(vdot(d-e,v2)/vlength(d-e)*vlength(v2)));
#local a2 = (acos(vdot(e-d,v1)/vlength(e-d)*vlength(v1)));
#local a3 = pi-a1-a2;
#local l = (sin(a1)/sin(a3))*vlength(e-d);
#local f = d + vnormalize(v1)*l;
#local t1 = vlength(f-a);
#local t2 = vlength(f-b);
#local t3 = vlength(f-c);
#if ((t1!=t2)|(t2!=t3)|(t1!=t3))
#render "help"
#local f =Center(a,c,b);
#end
f
#end
The only problem with it is that I have to check that the point it finds
is equidistant to all three points. I think it has to do with the
orientation of the points, since the correction only requires a reversal
of orientation to fix the problem.
--
Josh English
eng### [at] spiritone com
The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/
Post a reply to this message
|
![](/i/fill.gif) |