POV-Ray : Newsgroups : povray.general : general geometry question Server Time
7 Aug 2024 19:23:16 EDT (-0400)
  general geometry question (Message 19 to 28 of 28)  
<<< Previous 10 Messages Goto Initial 10 Messages
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

<<< Previous 10 Messages Goto Initial 10 Messages

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