|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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?
TIA
Thomas
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Samuel Benge" <stb### [at] hotmailcom> wrote:
>
> I already had some code for this laying around :)
>
Oops, the X & Y intersections were not in sync, and it wasn't handling
non-overlapping circles at all. Here's an improved version:
#declare Pt1 = <0.7, 0, 0>;
#declare Rad1 = 1.5;
#declare Pt2 = <-.5, 0.25, 0>;
#declare Rad2 = 1;
#declare D = vlength(Pt2-Pt1);
#declare T = (pow(Rad1+Rad2,2)-D*D)*(D*D-pow(Rad1-Rad2,2));
#if(T>0)
#declare K = -.25*sqrt(T);
#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*(Pt1.y+Pt2.y) +
..5*(Pt1.y-Pt2.y)*(Rad2*Rad2-Rad1*Rad1)/(D*D) + 2*(Pt1.x-Pt2.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}
}
#else
#warning "warning: circles do not overlap"
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thank you Samuel, this looks very good indeed. Over the weekend I ported the C
code mentioned here: http://paulbourke.net/geometry/2circle/ to a POV macro and
that does give me the same result. I might move to your way, was it is much more
POV like.
My first attempt at an animation is here:
http://legopov.blogspot.co.uk/
As mentioned, I am not sure the bottom part should move like that.
Thank you for your help,
Thomas
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> Thank you Samuel, this looks very good indeed. Over the weekend I ported the C
> code mentioned here: http://paulbourke.net/geometry/2circle/ to a POV macro and
> that does give me the same result. I might move to your way, was it is much more
> POV like.
>
> My first attempt at an animation is here:
> http://legopov.blogspot.co.uk/
>
> As mentioned, I am not sure the bottom part should move like that.
>
> Thank you for your help,
>
> Thomas
>
>
All parts should always move at the same rate. After all, it's not an
elastic.
Just adding another point on your spline under the bottom part, with the
same separation as the previous ones, should do the trick.
Alain
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Alain <kua### [at] videotronca> wrote:
> > Thank you Samuel, this looks very good indeed. Over the weekend I ported the C
> > code mentioned here: http://paulbourke.net/geometry/2circle/ to a POV macro and
> > that does give me the same result. I might move to your way, was it is much more
> > POV like.
> >
> > My first attempt at an animation is here:
> > http://legopov.blogspot.co.uk/
> >
> > As mentioned, I am not sure the bottom part should move like that.
> >
> > Thank you for your help,
> >
> > Thomas
> >
> >
> All parts should always move at the same rate. After all, it's not an
> elastic.
> Just adding another point on your spline under the bottom part, with the
> same separation as the previous ones, should do the trick.
>
>
>
>
> Alain
posted new video in animations binary section and continuing discussion in
povray.animations (Lego Garage door)
Thanks,
Thomas
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|