Circle Gesture and finding the middle

Hey everyone,

I am very new to mobile programming have this mobile project that has the player drawing a circle over an enemy or anywhere and in code it would require me to find the middle of that circle and launch a mortar projectile there.

This is a top down action game and the scale of the player to enemies is like a human to a middle sized dog (maybe up to waist) and these are seen from a UAV.

So basically I would like the code to flow this way:

  1. User draws circle (Circle will be traced with a line preferably)

  2. OPTIONAL: Able to draw only over enemy (This will many issues I’m guessing because I’m going to have a lot of enemies on screen at a time)

  3. The code finds the middle of the circle (Probably getting start/end point and adding the radius to it I’m not sure)

  4. Save that coordinate for bomb target and show an point on screen as target.

I know gestures like circles are not easy but I don’t need a super accurate or complex one because the middle point is the more important one.

If you simply sum the x’s and y’s and divide by the number of them, you’ll have the average position of all positions making up the circle. Should be approximately the middle. Note works with other shapes as well.