POV-Ray : Newsgroups : povray.general : general geometry question Server Time
11 Oct 2026 05:13:24 EDT (-0400)
  general geometry question (Message 1 to 28 of 28)  
From: Mark M  Wilson
Subject: general geometry question
Date: 21 Aug 2001 16:01:43
Message: <3B82C002.E75037D3@ncsl.dcr.state.nc.us>
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


Post a reply to this message

From: Ben Chambers
Subject: Re: general geometry question
Date: 21 Aug 2001 16:13:11
Message: <3b82c0d7@news.povray.org>
"Mark M. Wilson" <mmw### [at] ncsldcrstatencus> wrote in message
news:3B82C002.E75037D3@ncsl.dcr.state.nc.us...
> 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

Actually, you can do it with two points. Try this:

#declare P1 = <x1, y1, z1>;
#declare P2 = <x2, y2, z2>;

sphere {
    (P1+P2)/2, sqrt(sqr(x2-x1)+sqr(y2-y1)+sqr(z2-z1))
    texture {stuff}
}


Post a reply to this message

From: Ron Parker
Subject: Re: general geometry question
Date: 21 Aug 2001 16:16:15
Message: <slrn9o5gcg.huq.ron.parker@fwi.com>
On Tue, 21 Aug 2001 16:09:38 -0400, 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?

1) Correct.
2) My torus spline macro at http://www2.fwi.com/~parkerr/traces.html has
the equations you need in it, but you'll have to do a little work to extract
them.  Here's the relevant part:


          #local Axis=vnormalize(vcross((C-A),(B-A)));
          #local Base1=vnormalize(C-A);
          #local Base2=vnormalize(vcross(Axis,Base1));
          #local VB=<0.5*vlength(C-A),0,0>;
          #local VA=vcross(VB,z);
          #local VD=.5*<vdot(B-A,Base1),vdot(B-A,Base2),0>;
          #local VC=vcross(VD,z);
          #local Beta=((VD-VB).y*VA.x-(VD-VB).x*VA.y)/(VC.x*VA.y-VC.y*VA.x);
          #local Center=A+VD.x*Base1+VD.y*Base2+Beta*(VC.x*Base1+VC.y*Base2);
          #local Radius=vlength(Center-A);

There might be an easier way, but this one works for coplanar (but not
collinear) vectors A, B, and C.  The results are in the variables Axis,
Center, and Radius.  If you didn't need the axis, some of this could be
simplified a bit.

--
#macro R(L P)sphere{L __}cylinder{L P __}#end#macro P(_1)union{R(z+_ z)R(-z _-z)
R(_-z*3_+z)torus{1__ clipped_by{plane{_ 0}}}translate z+_1}#end#macro S(_)9-(_1-
_)*(_1-_)#end#macro Z(_1 _ __)union{P(_)P(-_)R(y-z-1_)translate.1*_1-y*8pigment{
rgb<S(7)S(5)S(3)>}}#if(_1)Z(_1-__,_,__)#end#end Z(10x*-2,.2)camera{rotate x*90}


Post a reply to this message

From: Mark M  Wilson
Subject: Re: general geometry question
Date: 21 Aug 2001 16:43:20
Message: <3B82C9C3.D71E4CF@ncsl.dcr.state.nc.us>
My only problem with that is that with only two points used, I can think
of at least THREE possible circles (i.e., with centers at different
vectors); two points could lie somewhere along either one of two of the
component semicircles, or the two points could be at either end of a
diameter of a circle with a different diameter.  Am I clear?
What I'm thinking is that given THREE coplanar points, only ONE possible
(coplanar) circle could encompass all three points.   Maybe I'm wrong
about there being only one such circle?

--Mark

Ben Chambers wrote:
> 
> Actually, you can do it with two points. Try this:
> 
> #declare P1 = <x1, y1, z1>;
> #declare P2 = <x2, y2, z2>;
> 
> sphere {
>     (P1+P2)/2, sqrt(sqr(x2-x1)+sqr(y2-y1)+sqr(z2-z1))
>     texture {stuff}
> }


Post a reply to this message

From: Mark M  Wilson
Subject: Re: general geometry question
Date: 21 Aug 2001 16:46:49
Message: <3B82CA95.4850921D@ncsl.dcr.state.nc.us>
Correction: I should say "at either end of the line segment equal in
length to the diameter of a noncongruent circle."
--Mark


"Mark M. Wilson" wrote:
> 
>  or the two points could be at either end of a diameter of a circle with a different

>  diameter. 


> --Mark
> 
> Ben Chambers wrote:
> >
> > Actually, you can do it with two points. Try this:
> >
> > #declare P1 = <x1, y1, z1>;
> > #declare P2 = <x2, y2, z2>;
> >
> > sphere {
> >     (P1+P2)/2, sqrt(sqr(x2-x1)+sqr(y2-y1)+sqr(z2-z1))
> >     texture {stuff}
> > }


Post a reply to this message

From: Ron Parker
Subject: Re: general geometry question
Date: 21 Aug 2001 16:47:08
Message: <slrn9o5i6e.i0a.ron.parker@fwi.com>
On Tue, 21 Aug 2001 16:51:15 -0400, Mark M. Wilson wrote:
>My only problem with that is that with only two points used, I can think
>of at least THREE possible circles

Actually, with just two points you can choose a center anywhere on the 
line that's equally distant from both points and draw a circle that goes 
through both points.  Thus, there are infinite solutions to the two-point
problem.

-- 
plane{-z,-3normal{crackle scale.2#local a=5;#while(a)warp{repeat x flip x}rotate
z*60#local a=a-1;#end translate-9*x}pigment{rgb 1}}light_source{-9red 1rotate 60
*z}light_source{-9rgb y rotate-z*60}light_source{9-z*18rgb z}text{ttf"arial.ttf"
"RP".01,0translate-<.6,.4,.02>pigment{bozo}}light_source{-z*3rgb-.2}//Ron Parker


Post a reply to this message

From: Mark M  Wilson
Subject: Re: general geometry question
Date: 21 Aug 2001 16:55:19
Message: <3B82CC93.2063EBB2@ncsl.dcr.state.nc.us>
Thanks! I'll look into it.  (BTW, I hope I was clear that I meant that
all three points should be along the full arc of the circle in
question.)  
Since I'm a POVray newbie, now all I have to do is figure out how to use
macros!
Maybe what I SHOULD have asked is, how to do the raw math myself to
figure out where to place the center of whatever torus or circle I
decide to place in my scene...  That would be, how to find the vector
for the ONE point which is equidistant from all three points.

(Macros are probably fine once you know what the heck you're doing, but
I just want to get started placing my objects in my project scene!)

Thanks again,
Mark

Ron Parker wrote:
> 
> 
> 1) Correct.
> 2) My torus spline macro at http://www2.fwi.com/~parkerr/traces.html has
> the equations you need in it, but you'll have to do a little work to extract
> them.  Here's the relevant part:
> 
>           #local Axis=vnormalize(vcross((C-A),(B-A)));
>           #local Base1=vnormalize(C-A);
>           #local Base2=vnormalize(vcross(Axis,Base1));
>           #local VB=<0.5*vlength(C-A),0,0>;
>           #local VA=vcross(VB,z);
>           #local VD=.5*<vdot(B-A,Base1),vdot(B-A,Base2),0>;
>           #local VC=vcross(VD,z);
>           #local Beta=((VD-VB).y*VA.x-(VD-VB).x*VA.y)/(VC.x*VA.y-VC.y*VA.x);
>           #local Center=A+VD.x*Base1+VD.y*Base2+Beta*(VC.x*Base1+VC.y*Base2);
>           #local Radius=vlength(Center-A);
> 
> There might be an easier way, but this one works for coplanar (but not
> collinear) vectors A, B, and C.  The results are in the variables Axis,
> Center, and Radius.  If you didn't need the axis, some of this could be
> simplified a bit.
> 
> --
> #macro R(L P)sphere{L __}cylinder{L P __}#end#macro P(_1)union{R(z+_ z)R(-z _-z)
> R(_-z*3_+z)torus{1__ clipped_by{plane{_ 0}}}translate z+_1}#end#macro S(_)9-(_1-
> _)*(_1-_)#end#macro Z(_1 _ __)union{P(_)P(-_)R(y-z-1_)translate.1*_1-y*8pigment{
> rgb<S(7)S(5)S(3)>}}#if(_1)Z(_1-__,_,__)#end#end Z(10x*-2,.2)camera{rotate x*90}


Post a reply to this message

From: Ben Chambers
Subject: Re: general geometry question
Date: 21 Aug 2001 17:01:09
Message: <3b82cc15@news.povray.org>
"Mark M. Wilson" <mmw### [at] ncsldcrstatencus> wrote in message
news:3B8### [at] ncsldcrstatencus...
> My only problem with that is that with only two points used, I can think
> of at least THREE possible circles (i.e., with centers at different
> vectors); two points could lie somewhere along either one of two of the
> component semicircles, or the two points could be at either end of a
> diameter of a circle with a different diameter.  Am I clear?
> What I'm thinking is that given THREE coplanar points, only ONE possible
> (coplanar) circle could encompass all three points.   Maybe I'm wrong
> about there being only one such circle?
>
> --Mark

No, you're right - I was thinking sphere.  Sorry. :)

...Chambers


Post a reply to this message

From: Ron Parker
Subject: Re: general geometry question
Date: 21 Aug 2001 17:18:37
Message: <slrn9o5k1f.i1c.ron.parker@fwi.com>
On Tue, 21 Aug 2001 17:03:15 -0400, Mark M. Wilson wrote:
>Maybe what I SHOULD have asked is, how to do the raw math myself to
>figure out where to place the center of whatever torus or circle I
>decide to place in my scene...  That would be, how to find the vector
>for the ONE point which is equidistant from all three points.

Well, that's exactly what you have in the sequence of assignments I 
gave you; it's not actually a macro, it's just the math.

The truth is that there are really an infinite number of points that 
are equidistant from all three points.  The code I gave you computes
the one that happens to lie in the same plane.  Essentially, what it 
does is what you'd do with a compass and straightedge: draw the line 
segment from A to B and the line segment from B to C, construct the
perpendicular bisector of each segment, and the center is where the 
two perpendicular bisectors cross.  It's made somewhat more ugly by 
the fact that I did a basis transform to make the third step (finding
the intersection of the two bisectors) easier mathematically, but 
that's the basic idea.  I've tried to explain some of the math below.

(The rest of the points that are equidistant are of the form 
Center + m * Axis, for real values of m.  In other words, the axis of 
the uniquely-determined cylinder that all three points lie on.)

>>           #local Axis=vnormalize(vcross((C-A),(B-A)));

Axis is the direction of the line that is equidistant from all three
points.  We don't know its position in space yet, but we know which
direction it points.  It's also the third basis vector, but we don't
care about that so much.

>>           #local Base1=vnormalize(C-A);
>>           #local Base2=vnormalize(vcross(Axis,Base1));
>>           #local VB=<0.5*vlength(C-A),0,0>;
>>           #local VA=vcross(VB,z);
>>           #local VD=.5*<vdot(B-A,Base1),vdot(B-A,Base2),0>;
>>           #local VC=vcross(VD,z);

This is the basis transform and construction of perpendicular bisectors
rolled into one.  VA and VC are the bisectors, and VB and VD are their
offsets from point A (which is the origin in the alternate basis.)  They 
aren't much use, though, because the basis for these vectors is not x,y,z 
as with "normal" vectors.  In fact, note that the z component of all four 
vectors is zero.  That's why I chose this basis: it makes the next line a 
lot easier.

>>           #local Beta=((VD-VB).y*VA.x-(VD-VB).x*VA.y)/(VC.x*VA.y-VC.y*VA.x);

Beta is just an intermediate value.  It has physical significance, in that
it is the distance to the center along VC from the center to the line from
A to B (and also, of course, the distance along VA from the center to the
line from A to C) but it didn't really need to be separated out, except
to make the next line easier to read.  The mess above is just the solution
of two equations (the equations of the two bisectors) in two unknowns (the 
center of the circle in my alternate basis; z is known because it's zero.
Setting z to something besides zero would give you one of the other points
that's equidistant from all three points, conceptually, except that the
z component is ignored in the next line.)

>>           #local Center=A+VD.x*Base1+VD.y*Base2+Beta*(VC.x*Base1+VC.y*Base2);

In my alternate basis, the center is just VD+Beta*VC.  This line incorporates
that with the inverse basis transform to get back into x,y,z space.

>>           #local Radius=vlength(Center-A);

This line should be pretty obvious: if the center really is the center, then
the radius is the distance from the center to one of the points.  I picked
A because it's first.  I could have used B or C instead.

-- 
plane{-z,-3normal{crackle scale.2#local a=5;#while(a)warp{repeat x flip x}rotate
z*60#local a=a-1;#end translate-9*x}pigment{rgb 1}}light_source{-9red 1rotate 60
*z}light_source{-9rgb y rotate-z*60}light_source{9-z*18rgb z}text{ttf"arial.ttf"
"RP".01,0translate-<.6,.4,.02>pigment{bozo}}light_source{-z*3rgb-.2}//Ron Parker


Post a reply to this message

From: Ron Parker
Subject: Re: general geometry question
Date: 21 Aug 2001 17:24:26
Message: <slrn9o5kcd.i1c.ron.parker@fwi.com>
On Tue, 21 Aug 2001 14:02:43 -0700, Ben Chambers wrote:
>
>No, you're right - I was thinking sphere.  Sorry. :)

It's even worse with spheres: there are an infinite number of spheres that
go through any given two points.  In fact, there are an infinite number of
spheres that go through any given THREE points.  You need four points to
uniquely determine a sphere.

--
#macro R(L P)sphere{L __}cylinder{L P __}#end#macro P(_1)union{R(z+_ z)R(-z _-z)
R(_-z*3_+z)torus{1__ clipped_by{plane{_ 0}}}translate z+_1}#end#macro S(_)9-(_1-
_)*(_1-_)#end#macro Z(_1 _ __)union{P(_)P(-_)R(y-z-1_)translate.1*_1-y*8pigment{
rgb<S(7)S(5)S(3)>}}#if(_1)Z(_1-__,_,__)#end#end Z(10x*-2,.2)camera{rotate x*90}


Post a reply to this message

From: Jamie Davison
Subject: Re: general geometry question
Date: 21 Aug 2001 17:54:37
Message: <MPG.15ece9a6d12411d69899c5@news.povray.org>
I have a question.  And please bear in mind that my maths is not the 
best.

How do you get a solution if all three points are in a perfectly straight 
line, e.g.:
<0,0,0>, <1,0,0>, <2,0,0>

Apart from using the limited accuracy of numerical values in POV, how do 
you draw a circle such that its circumference passes through all three 
points?

Or am I misunderstaning the original question?

Bye for now,
     Jamie.


Post a reply to this message

From: Bill DeWitt
Subject: Re: general geometry question
Date: 21 Aug 2001 17:55:49
Message: <3b82d8e5$1@news.povray.org>
"Ron Parker" <ron### [at] povrayorg> wrote in message
news:slr### [at] fwicom...
> On Tue, 21 Aug 2001 14:02:43 -0700, Ben Chambers wrote:
> >
> >No, you're right - I was thinking sphere.  Sorry. :)
>
> It's even worse with spheres:

    That's right, the infinte number of speres that intersect two points is
much larger than the infinite number of circles that intersect two points.


Post a reply to this message

From: Warp
Subject: Re: general geometry question
Date: 21 Aug 2001 18:14:08
Message: <3b82dd30@news.povray.org>
Jamie Davison <jam### [at] ntlworldcom> wrote:
: How do you get a solution if all three points are in a perfectly straight 
: line, e.g.:
: <0,0,0>, <1,0,0>, <2,0,0>

  There's no solution. Not finite one, that is.

  If you try to calculate it, you probably get a division by 0 or another
similar undefined result.

  Geometrically this is explained by thinking that the only solution is
a circle with infinite radius and the center being at infinity. That is,
the circumference is a straight line.

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Ron Parker
Subject: Re: general geometry question
Date: 21 Aug 2001 18:15:48
Message: <slrn9o5ncn.i39.ron.parker@fwi.com>
On Tue, 21 Aug 2001 17:55:49 -0400, Bill DeWitt wrote:
>
>"Ron Parker" <ron### [at] povrayorg> wrote in message
>news:slr### [at] fwicom...
>> On Tue, 21 Aug 2001 14:02:43 -0700, Ben Chambers wrote:
>> >
>> >No, you're right - I was thinking sphere.  Sorry. :)
>>
>> It's even worse with spheres:
>
>    That's right, the infinte number of speres that intersect two points is
>much larger than the infinite number of circles that intersect two points.

Let's not start that again.

-- 
plane{-z,-3normal{crackle scale.2#local a=5;#while(a)warp{repeat x flip x}rotate
z*60#local a=a-1;#end translate-9*x}pigment{rgb 1}}light_source{-9red 1rotate 60
*z}light_source{-9rgb y rotate-z*60}light_source{9-z*18rgb z}text{ttf"arial.ttf"
"RP".01,0translate-<.6,.4,.02>pigment{bozo}}light_source{-z*3rgb-.2}//Ron Parker


Post a reply to this message

From: Bill DeWitt
Subject: Re: general geometry question
Date: 21 Aug 2001 18:20:24
Message: <3b82dea8$1@news.povray.org>
"Jamie Davison" <jam### [at] ntlworldcom> wrote :
>
> Apart from using the limited accuracy of numerical values in POV, how do
> you draw a circle such that its circumference passes through all three
> points?

    I think the theorem or what ever goes something like, "For any three
points which are not on a line, there is one circle that intersects all
three points"


Post a reply to this message

From: Bill DeWitt
Subject: Re: general geometry question
Date: 21 Aug 2001 18:23:21
Message: <3b82df59$1@news.povray.org>
"Ron Parker" <ron### [at] povrayorg> wrote :
>
> Let's not start that again.

    I agree. We have already gone over it half an infinite number of times.


Post a reply to this message

From: Mark M  Wilson
Subject: Re: general geometry question
Date: 21 Aug 2001 18:23:55
Message: <3B82E079.6E533923@worldnet.att.net>
Sorry, Jamie --
I forgot to specify in my original question that the three points must
NOT be colinear, but SHOULD be coplanar (and anyone who knows geometry
knows that given any three points in 3D space, exactly one plane can
contain all three.)

I do in fact want to find the center point of the circle whose
circumference passes through the OTHER three points. :-)

--Mark

Jamie Davison wrote:
> 
> I have a question.  And please bear in mind that my maths is not the
> best.
> 
> How do you get a solution if all three points are in a perfectly straight
> line, e.g.:
> <0,0,0>, <1,0,0>, <2,0,0>
> 
> Apart from using the limited accuracy of numerical values in POV, how do
> you draw a circle such that its circumference passes through all three
> points?
> 
> Or am I misunderstaning the original question?
> 
> Bye for now,
>      Jamie.


Post a reply to this message

From: Mark M  Wilson
Subject: Re: general geometry question
Date: 21 Aug 2001 18:27:22
Message: <3B82E149.2280742B@worldnet.att.net>
Bill DeWitt wrote:
> 
> 
>     I think the theorem or what ever goes something like, "For any three
> points which are not on a line, there is one circle that intersects all
> three points"


THAT'S IT EXACTLY!!! And I'm trying to figure out how to find the vector
of the center of such a circle.

--Mark


Post a reply to this message

From: Warp
Subject: Re: general geometry question
Date: 21 Aug 2001 18:36:28
Message: <3b82e26c@news.povray.org>
Bill DeWitt <bde### [at] cflrrcom> wrote:
:     That's right, the infinte number of speres that intersect two points is
: much larger than the infinite number of circles that intersect two points.

  If we think about dimensions, then yes. With circles and two points, there's
a 1-dimensional line which is the solution to the problem. With spheres and
two points, there's 2-dimensional plane which is the solution.

  However, if we count the amount of circles and spheres, they are equal.

  Of course it's a bit odd to speak about "equal" and "bigger than" when
dealing with infinite, but it's defined in math.
  This creates some oddities. For example, there are as many natural numbers
(ie. positive integer numbers) as there are rational numbers (ie.
integer/integer). This is because each rational number can be indexed with
a pair of natural numbers.
  However, there are more real numbers than there are rational numbers.
This is because there's no way to index every real number with natural
numbers (or even rational numbers).
  This is odd knowing that given any two real numbers there will be an infinite
amount of rational numbers between them, and given any two rational numbers
there will be an infinite amount of real numbers between them. Yet there are
more real numbers than rational numbers.

-- 
#macro N(D,I)#if(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2pigment{
rgb M()}}N(D,(D[I]>99?I:I+1))#end#end#macro M()<mod(D[I],13)-6,mod(div(D[I
],13),8)-3,10>#end blob{N(array[6]{11117333955,
7382340,3358,3900569407,970,4254934330},0)}//                     - Warp -


Post a reply to this message

From: Chris Jeppesen
Subject: Re: general geometry question
Date: 21 Aug 2001 19:04:46
Message: <3b82e90e@news.povray.org>
"Mark M. Wilson" <mmw### [at] ncsldcrstatencus> wrote in message
news:3B82C002.E75037D3@ncsl.dcr.state.nc.us...
> 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?

Right. Constructing the circle with compass and straightedge is easy.
1) draw a line segment between each pair of points
2) construct perpindicular bisectors to each segment
3) the point where the three bisectors meet is the center. Set the compass
at the center, the radius to the distance from center to any of the points,
and draw.

you really only need two perp bisectors to make this work.

>
> 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?

Hmmm,

#macro LineThroughPointWithSlope(M,P1,B)
  // Find intercept B given slope M and point to pass through P1
  #declare B=P1.y-(M*P1.x);
#end

#macro LineThroughTwoPoints(P1,P2,M,B)
  // Given two points in a plane, find
  // slope m and intercept b of line
  // through both lines
  #declare M=(P2.y-P1.y)/(P2.x-P1.x);
  LineThroughPointWithSlope(M,P1,B)
#end

#macro PerpendicularBisector(P1,P2,M,B)
  // Given two points in a plane, find
  // slope m and intercept b of perpendicular
  // bisector
  #local M2=0;
  LineThroughTwoPoints(P1,P2,M2,B)
  #declare M=-1/M2;
  LineThroughPointWithSlope(M,(P1+P2)/2,B)
#end

#macro FindIntersection(M1,B1,M2,B2,P)
  // given two lines slopes and intercepts, find the intersecting point P
  // M1*x+B1=M2*X+B2
  // B1-B2=M2*x-M1*x
  // (B1-B2)/(M2-M1)=x
  // y=M1*x+B1
  #local X=(B1-B2)/(M2-M1);
  #local Y=M1*X+B1;
  #declare P=<X,Y,0>
#end

#macro ThreePointCircle(P1,P2,P3,C,R)
  #local M1=0;
  #local M2=0;
  #local B1=0;
  #local B2=0;
  PerpendicularBisector(P1,P2,M1,B1)
  PerpendicularBisector(P2,P3,M2,B2)
  #declare C=<0,0,0>;
  FindIntersection(M1,B1,M2,B2,Center)
  #declare R=vlength(Center-P1);
#end

#declare Point1=<1,2,0>;
#declare Point2=<3,4,0>;
#declare Point3=<2,-1,0>;
#declare Center=<0,0,0>;
#declare Radius=0;
ThreePointCircle(Point1,Point2,Point3,Center,Radius)

plane {
  z,0
  pigment {checker color rgb 1 color rgb 0}
}

sphere {
  Point1,0.25
  pigment {color rgb <1,0,0>}
}

sphere {
  Point2,0.25
  pigment {color rgb <0,1,0>}
}

sphere {
  Point3,0.25
  pigment {color rgb <0,0,1>}
}

torus {
  Radius,0.125
  rotate x*90
  translate Center
  pigment {color rgb <1,1,0>}
}

camera {
  location <0,0,-15>
  look_at <0,0,0>
}

light_source {
  <2000,2000,-2000>
  color 1.5
}

This only works in 2 dimensions, ie z1=z2=z3. Extending to 3 dimensions is a
more complicated problem than I care to think about now.

>
> TIA,
> Mark M. Wilson


Post a reply to this message

From: Ron Parker
Subject: Re: general geometry question
Date: 21 Aug 2001 19:16:39
Message: <slrn9o5quq.i4e.ron.parker@fwi.com>
On 21 Aug 2001 18:36:28 -0400, Warp wrote:
>  If we think about dimensions, then yes. With circles and two points, there's
>a 1-dimensional line which is the solution to the problem. With spheres and
>two points, there's 2-dimensional plane which is the solution.
>
>  However, if we count the amount of circles and spheres, they are equal.

Actually, I think the result is that there are more 2-vectors than reals.

-- 
#local R=<7084844682857967,0787982,826975826580>;#macro L(P)concat(#while(P)chr(
mod(P,100)),#local P=P/100;#end"")#end background{rgb 1}text{ttf L(R.x)L(R.y)0,0
translate<-.8,0,-1>}text{ttf L(R.x)L(R.z)0,0translate<-1.6,-.75,-1>}sphere{z/9e3
4/26/2001finish{reflection 1}}//ron.parker@povray.org My opinions, nobody else's


Post a reply to this message

From: Ron Parker
Subject: Re: general geometry question
Date: 21 Aug 2001 19:22:23
Message: <slrn9o5r9i.i4e.ron.parker@fwi.com>
On Tue, 21 Aug 2001 16:04:44 -0700, Chris Jeppesen wrote:
>This only works in 2 dimensions, ie z1=z2=z3. Extending to 3 dimensions is a
>more complicated problem than I care to think about now.

You need a basis transform to get it back into 2 dimensions, as with my
solution.

-- 
#local R=rgb 99;#local P=R-R;#local F=pigment{gradient x}box{0,1pigment{gradient
y pigment_map{[.5F pigment_map{[.3R][.3F color_map{[.15red 99][.15P]}rotate z*45
translate x]}]#local H=pigment{gradient y color_map{[.5P][.5R]}scale 1/3}[.5F
pigment_map{[.3R][.3H][.7H][.7R]}]}}}camera{location.5-3*z}//only my opinions


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: general geometry question
Date: 21 Aug 2001 19:45:04
Message: <3B82F267.36412849@hotmail.com>
"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?

Hello Mark

I had to go and dig up some of my old 
macros to solve this problem of yours.

The code below solves it.

It draws a circle through any 3 points
in 3D-space that are not co-linear.

(Not very much coding is really needed
to find the coordinates for the center
of the circle, the radius and the normal
vector for the plane that the circle lies
in. But I have added some code to 
visualize it all.) 

The code also shows how to make a sphere
touch any 4 points in 3D-space that are
not co-planar (Hmmm... I wonder if it's
correct to say that about points.)

Have fun !


Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Copyright 2001 by Tor Olav Kristensen
// http://www.crosswinds.net/~tok
// http://hjem.sol.no/t-o-k
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

// How to make a circle touch 3 points in 3D-space.

#version 3.1;

#include "colors.inc"

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Macros to do the dirty work

// Returns the point that lies in all the 3 planes.
#macro pl2pl2pl(pPlane1, vPlane1, pPlane2, vPlane2, pPlane3, vPlane3)

  ((vdot(pPlane1, vPlane1)*vcross(vPlane2, vPlane3) +
    vdot(pPlane2, vPlane2)*vcross(vPlane3, vPlane1) +
    vdot(pPlane3, vPlane3)*vcross(vPlane1, vPlane2))/
    vdot(vPlane1, vcross(vPlane2, vPlane3)))

#end // macro pl2pl2pl


#macro CircleTouches3Points(p1, p2, p3, pCenter, Radius, vPlane)

  #local v12 = p2 - p1;
  #local v13 = p3 - p1;

  #declare vPlane = vnormalize(vcross(v13, v12));
  #declare pCenter = pl2pl2pl(
                       p1 + p1, vPlane,
                       p1 + p2, v12,
                       p1 + p3, v13
                     )/2;

  #declare Radius = vlength(p1 - pCenter);

#end // macro CircleTouches3Points

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Define problem

#declare pA = <1, 2, 3>;
#declare pB = <-2, 0, -1>;
#declare pC = <1, -3, 3>;

sphere { pA, 0.2 pigment { color Red*2 } }
sphere { pB, 0.2 pigment { color Green*2 } }
sphere { pC, 0.2 pigment { color Magenta*2 } }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Solve problem

#declare pCtr = <0, 0, 0>;
#declare R = 0;
#declare vPl = <0, 0, 0>; 
 
CircleTouches3Points(pA, pB, pC, pCtr, R, vPl)

difference {
  cylinder { -0.05*vPl, 0.05*vPl, R + 0.04 }
  cylinder { -0.06*vPl, 0.06*vPl, R - 0.04 }
  translate pCtr
  pigment { color rgb <0, 1, 1> } 
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

background { color Blue/2 }

light_source { 100*<1, 1, -1> color White }

camera {
  location pCtr + 8*vPl
  look_at pCtr
}

/*
// Uncomment region below to see how to make a sphere touch 4 points.
// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Another slave

#macro SphereTouches4Points(p0, p1, p2, p3, pCenter, Radius)

  #declare pCenter = pl2pl2pl(
                    p0 + p1, p1 - p0,
                    p0 + p2, p2 - p0,
                    p0 + p3, p3 - p0
                  )/2;
  #declare Radius = vlength(p0 - pCenter);

#end // macro SphereTouches4Points

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// Extend problem

#declare pD = <1, 0, 1>;

sphere { pD, 0.2 pigment { color Blue*2 } }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
// And solve that too

#declare pCtr = <0, 0, 0>;
#declare R = 0;

SphereTouches4Points(pA, pB, pC, pD, pCtr, R)

sphere { pCtr, R pigment { color White } }

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

camera {
  location <2, 2, -3>*3
  look_at <0, 1, 0>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =
*/


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: general geometry question
Date: 21 Aug 2001 20:33:25
Message: <3B82FDB9.45E83FA@hotmail.com>
Tor Olav Kristensen wrote:
>...
> The code also shows how to make a sphere
> touch any 4 points in 3D-space that are
> not co-planar (Hmmm... I wonder if it's
> correct to say that about points.)
>...

To see an interesting property of this 
sphere, uncomment my code as described
within it, and add these lines of code to
the end of the script.


Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =

CircleTouches3Points(pA, pB, pD, pCtr, R, vPl)

difference {
  cylinder { -0.05*vPl, 0.05*vPl, R + 0.04 }
  cylinder { -0.06*vPl, 0.06*vPl, R - 0.04 }
  translate pCtr
  pigment { color Cyan } 
}

CircleTouches3Points(pA, pC, pD, pCtr, R, vPl)

difference {
  cylinder { -0.05*vPl, 0.05*vPl, R + 0.04 }
  cylinder { -0.06*vPl, 0.06*vPl, R - 0.04 }
  translate pCtr
  pigment { color Cyan } 
}

CircleTouches3Points(pB, pC, pD, pCtr, R, vPl)

difference {
  cylinder { -0.05*vPl, 0.05*vPl, R + 0.04 }
  cylinder { -0.06*vPl, 0.06*vPl, R - 0.04 }
  translate pCtr
  pigment { color Cyan } 
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7 =


Post a reply to this message

From: David Fontaine
Subject: Re: general geometry question
Date: 23 Aug 2001 02:24:03
Message: <3B849F30.593BAE27@faricy.net>
Bill DeWitt wrote:
> 
> > It's even worse with spheres:
> 
>     That's right, the infinte number of speres that intersect two points is
> much larger than the infinite number of circles that intersect two points.

Exactly.  I'm glad someone sees it my way.  ;)

-- 
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

From: David Fontaine
Subject: Re: general geometry question
Date: 23 Aug 2001 02:25:56
Message: <3B849F9E.21B330A4@faricy.net>
Warp wrote:
> 
>   This is odd knowing that given any two real numbers there will be an infinite
> amount of rational numbers between them, and given any two rational numbers
> there will be an infinite amount of real numbers between them. Yet there are
> more real numbers than rational numbers.

And given any two real numbers, there will be an infinite amount of real
numbers between them.  ;)

-- 
David Fontaine  <dav### [at] faricynet>  ICQ 55354965
My raytracing gallery:  http://davidf.faricy.net/


Post a reply to this message

From: Josh English
Subject: Re: general geometry question
Date: 23 Aug 2001 15:11:08
Message: <3B8554E5.C1B6BADC@spiritone.com>
"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] spiritonecom
The POV-Ray Cyclopedia http://www.spiritone.com/~english/cyclopedia/


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: general geometry question
Date: 23 Aug 2001 22:14:26
Message: <3B85B85A.ABCC61CE@hotmail.com>
Hi Josh.

I like your idea to use the "Law of Sines".

So here is a macro I came up with after I
messed around for a while with a pen, paper
and a ruler:


#macro pCircleCenter(pA, pB, pC)

  #local vBA = vnormalize(pA - pB);
  #local vBC = vnormalize(pC - pB);
  #local CosABC = vdot(vBA, vBC);
  #local SinABC = vlength(vcross(vBA, vBC));
  #local vBAn = vnormalize(vBC - vBA*CosABC);
  #local vBCn = vnormalize(vBA - vBC*CosABC);

  ((pA + pB + vlength(vcross(pC - pA, vBCn))/SinABC*vBAn)/2)

#end // macro pCircleCenter


I haven't tested it much, so I don't know
if it has the same problem as you say that
your macro has.

I.e.: That the macro sometimes have to 
re-arrange the order of the points.


Tor Olav


Josh English wrote:
> 
> "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.


Post a reply to this message

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