Hi,
My Pharo has no CircleAnimeMorph (yet).
And you code seems to have a } missing?
Peter
What i would recommend is to not mix morphs and math.
Put the implementation into clean and separate class(es),
which takes 2 circles (like point + raduis pair for each), and
provides an interface
for testing whether circles intersect as well as finding intersection point(s).
Then when you done, you can use it anywhere, including morphs.
--
On 24 September 2012 01:54, irfankhan1 <irfankhan@hotmail.ca> wrote:
> I solved this intersection of points �using this link
> http://paulbourke.net/geometry/2circle/
> <http://paulbourke.net/geometry/2circle/>
>
> Here is my workspace code
> |b b1 r r1 r2 d d1|
>
> b1:= CircleAnimeMorph �new.
> b1 center: 100@100.
> b1 openInWorld.
> b:= CircleAnimeMorph �new.
> b openInWorld.
> d:= �b1 center dist: b center. "distance between 2 circles"
> r:=b1 bounds �width /2. �"radius of first circle"
> r1:=b bounds width/2. "radius of second Circle"
> r2:=r + r1 .
>
> (d )< (r2)
>
> ifTrue: [| a h mid c c1 myPen �h1 h2 mx my mc mc1|
>
> � � � � a := (r squared - r1 squared + d squared) / (2 * d).
> � � � � h := (r squared - a squared) sqrt.
> � � � �h1:= b center y - b1 center y.
> � � � �h2:= b center x - b1 center x.
> � � � mx:=a * (b center x - b1 center x)/d.
> � � � my:=a* (b center y �- � b1 center y)/d.
>
> � � � � �mid := ((mx)+(b1 center x) �@ (b1 center y )+(my) ) � " calculates
> mid point between 2 intersecting circles (p2)"
> � � � � {
> � � � � � � � � � � � mc:=(h * h1)/d.
> � � � � � � � � � � � mc1:=(h * h2)/d.
> � � � � � � � � � � � c:=(mid x + �mc )@ (mid y - mc1 )."Actual Intersecting
> points"
> � � � � � � � � � � � c1:=(mid x -mc) @ (mid y + mc1 )."Actual Intersecting
> points"
> � � � � � � � � � � � Transcript show: (c); show: (c1); cr}.
> � � � � � � � � � � � myPen := Pen new.
> � � � � � � � � � � � myPen color: Color �red.
> � � � � � � � � � � � myPen �putDotOfDiameter: 5 at: mid.
> � � � � � � � � � � � myPen �putDotOfDiameter: 5 at: c1.
> � � � � � � � � � � � myPen �putDotOfDiameter: 5 at: c.].
>
>
> �Can any one help me make this a methods ,I wanna make this a intersection
> method �which will do all this
> when i say
> b1 intersection:b. should do all of this and draw colored dots at
> intersecting points
>
>
>
>
> --
> View this message in context: http://forum.world.st/Get-the-point-of-Intersection-for-Morphs-tp4646066p4648614.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
Best regards,
Igor Stasenko.