Hi Colin,
Extracting the code from your explanation, I get:
on FindCenter(p1, p2)
dx = p2[1]-p1[1]
dy = p2[2]-p1[2]
angletocenter = atan(dx,dy) - pi*.75
distancetocenter = sqrt((dx*dx+dy*dy)*.5)
return p1 - point(sin(angletocenter)*distancetocenter,cos(angletocenter)*distancetocente
r)
end
On my machine, this produces the same result about 50% faster:
on mFindCenter(aStartLoc,anEndLoc) tChord = anEndLoc - aStartLoc return aStartLoc + [(tChord.locH + tChord.locV) / 2.0, \ (tChord.locV - tChord.locH) / 2.0] end
It is based on the fact that "The triangle that forms the center and the two points has two sides the same length".
My one also uses the fact that the two sides are the same, in the sqrt((dx*dx+dy*dy)*.5) line. The main difference between mine and yours is that mine plots an arc, and yours makes a circle and then cuts out the bit that's needed. For my approach I needed to know the initial angle to the center (the angletocenter = atan(dx,dy) - pi*.75 line).
It's probably true that I could have used your approach for working out the center of the circle, but I still can't get my mind around the method you use for adding or subtracting the horizontal coordinate from the vertical one, and vice versa! Certainly a user would prefer yours if they wanted to watch the arc being drawn as they drag.
In any case, my example movie has a create time of 11:31am this morning, and a last modified time of 12:00pm. I felt pretty pleased about working out a way to do it at all, and having an example file to post 29 minutes later! The 12:23pm post time is because writing up the e-mail took nearly as long as solving the whole problem!
[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
