|
|
"Thomas" <tho### [at] gmxnet> wrote:
> Hi,
>
> For my animation (see animations groups, Lego ladder) I need to calculate the
> intersection between two circles. Does anyone have have an example of this they
> would like to share?
>
I already had some code for this laying around :) It uses calculations from this
page: http://2000clicks.com/mathhelp/GeometryConicSectionCircleIntersection.aspx
The circles are assumed to be laying along the X & Y axes and centered at Z=0.
// code //
#declare Pt1 = <-.7,0,0>;
#declare Rad1 = 1.5;
#declare Pt2 = <.75,0,0>;
#declare Rad2 = 1;
#declare D = vlength(Pt2-Pt1);
#declare K = .25*sqrt((pow(Rad1+Rad2,2)-D*D)*(D*D-pow(Rad1-Rad2,2)));
#declare IntersectX = (.5*(Pt2.x+Pt1.x) +
..5*(Pt2.x-Pt1.x)*(Rad1*Rad1-Rad2*Rad2)/(D*D) + 2*(Pt2.y-Pt1.y)*K/(D*D));
#declare IntersectY = (.5*(Pt2.y+Pt1.y) +
..5*(Pt2.y-Pt1.y)*(Rad1*Rad1-Rad2*Rad2)/(D*D) + 2*(Pt2.x-Pt1.x)*K/(D*D));
// display circles
union{
torus{Rad1, 3/image_width rotate x*90 translate Pt1}
torus{Rad2, 3/image_width rotate x*90 translate Pt2}
pigment{rgb x}
}
// display intersection
union{
cylinder{
-y*2,y*2,3/image_width
translate x*IntersectX
}
cylinder{
-x*2,x*2,3/image_width
translate y*IntersectY
}
pigment{rgb x+y}
finish{ambient 1 diffuse 0}
}
// end code //
Hope this helps!
Sam
Post a reply to this message
|
|