Thanks very much to all who replied including: Franz-Josef Behr, Berk Charlton, Jose 
Quispe, Jacques Paris, and Russell Lawley.

---------------
Jacques provided me with his PLine_Intersect.MBX, also available on his website. 

---------------
Many pointed me in the direction of the IntersectNodes() function in MapBasic

---------------
Jennifer Minnick also pointed out helpful pages in geometric math at:

http://astronomy.swin.edu.au/~pbourke/geometry/2circle/

http://mathforum.org/library/drmath/view/55184.html

---------------
Plus the source code from Dr. Behr:

pn1, pn2 are the points of intersection.

type xyPoint
      x as float
      y as float
end type

'----------------------------------------------------------------------
function intersectcircles(p1, p2 as xyPoint, byval r1, byval r2 as 
float, pn1, pn2 as xyPoint) as logical
'----------------------------------------------------------------------
   dim h, q, p, s, dx, dy as float
   dim pf as xyPoint

   OnError Goto STANDARD_ERROR_HANDLING

   'print "intersectcircles " + str$(r1) + " " + str$(r2)
   s = xydistance (p1,p2)
   'print "s: " + str$(s)
   if (s > 0) and (s < r1+r2) then
      p  = (s*s + r1*r1 - r2*r2) / (2*s)
      'print "p: " + str$(p)
      if ((r1*r1 - p*p) < 0) then
         intersectcircles = FALSE
         exit function
      end if
      h  = sqr(r1*r1 - p*p)
      print "p " + str$(p)
      dx = (p2.x - p1.x)
      dy = (p2.y - p1.y)
      pf.x = p1.x + dx*p/s
      pf.y = p1.y + dy*p/s
      pn1.x = pf.x + dy*h/s
      pn1.y = pf.y - dx*h/s
      pn2.x = pf.x - dy*h/s
      pn2.y = pf.y + dx*h/s
      intersectcircles = TRUE
   else
      pn1.x = p1.x
      pn1.y = p1.y
      pn2.x = p1.x
      pn2.y = p1.y
      intersectcircles = FALSE
   end if
   exit function
STANDARD_ERROR_HANDLING:
   note error$()
end function 'intersectCircels

'----------------------------------------------------------------------
function xydistance(p1, p2 as xyPoint) as float
'----------------------------------------------------------------------
   dim dx, dy as float
   'xydistance = distance (p1.x, p1.y, p2.x, p2.y, "m")
   dx = p2.x - p1.x   dy = p2.y - p1.y
   xydistance = sqr(dx*dx + dy*dy)
end function


---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12166

Reply via email to