Cicle Detection

Blitz3D Forums/Blitz3D Programming/Cicle Detection

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Just knocked this together...

The function returns true or false depending on if the circles are touching or not. Send in the x y and radius of each circle... The code under the function is just for demo purposes so kill it off once you've got the idea!

Function incircle(x1,y1,r1,x2,y2,r2)
	x=(x1-x2)
	y=(y1-y2)
	If Sqr((x*x)+(y*y))<= (r1+r2) Then Return True Else Return False
End Function





; example code... just to show off the function

Graphics 640,480

Repeat

	x1=Rand(0,640)
	y1=Rand(0,480)
	r1=Rand(10,100)
	
	x2=Rand(0,640)
	y2=Rand(0,480)
	r2=Rand(10,100)
	
	Oval x1-r1,y1-r1,r1*2,r1*2,False
	Oval x2-r2,y2-r2,r2*2,r2*2,False
	
	Text 0,0,incircle(x1,y1,r1,x2,y2,r2)
	
	WaitKey
	Cls
	
Until KeyHit(1)