POV-Ray : Newsgroups : povray.general : general geometry question Server Time
7 Aug 2024 17:25:53 EDT (-0400)
  general geometry question (Message 1 to 10 of 28)  
Goto Latest 10 Messages Next 10 Messages >>>
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

Goto Latest 10 Messages Next 10 Messages >>>

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