Function to detect a point in a circle?

BlitzMax Forums/BlitzMax Beginners Area/Function to detect a point in a circle?

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.

Calculate the distance of the point from the center of the circle.

Distance# = Sqr((Px#-Cx#)^2 + (Py#-Cy#)^2)
If Distance# < Radius# Then InCircle()

Radius# is half the width of the circle.

If on the other hand you want to know if two circles collide, then do this:

Calculate distance between circle centers:

Distance# = Sqr((C2x#-C1x#)^2 + (C2y#-C1y#)^2)
If Distance# < (Radius1#+Radius2#) Then Colliding()