Circle overlap formula

BlitzMax Forums/BlitzMax Programming/Circle overlap formula

Hi :)

I need a function to get overlaping between Circle => Circle ?

Any idea :) ?

Function RectsOverlap:Int(x0, y0, w0, h0, x2, y2, w2, h2)
    If x0 > (x2 + w2) Or (x0 + w0) < x2 Then Return False
    If y0 > (y2 + h2) Or (y0 + h0) < y2 Then Return False
    Return True
End Function

Function CircRectsOverlap(x0, y0, w0, h0, cx, cy, r)
    Local testX:Int=cX
    Local testY:Int=cY
    If TestX < x0 Then TestX=x0
    If TestX > (x0+w0) Then TestX=(x0+w0)
    If TestY < y0 Then Testy=y0
    If TestY > (y0+h0) Then Testy=(y0+h0)

    Return ((cX-TestX)*(cX-TestX)+(cY-TestY)*(cY-TestY))<r*r
End Function


((x0-x1)^2+(y0-y1)^2)^0.5 < R0+R1
(ie. if the distance between the two centres is less than the sum of the two radus)

For real circles. DOnt know how relevent to your program

Many thanks H&K :)

by the way, using ^ is rather slow, so use
sqr((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1))

You could also try not using sqr or ^0.5 and using
{r0+r1)*(r0+r1)