Touch Gestures - Recognising a Circle

Hi there, does anyone have any ideas (conceptually) how you’d go about recognising when the user has encircled and object with their finger?

I was thinking about creating a series of invisible dummy objects, and it ‘hit’ in the correct order, would signify a circle…but this seems rather clumsy and I wonder if there’s a more elegant solution?

BTW I did check out FingerGestures on the Asset store, but it doesn’t support this particular gesture as yet.

Thanks

I’ve not done this, but the first thing that comes to mind is to track the last 3 points hit (A, B, C, in that order, where C is the latest).

Get the normalized delta vector between points A and B, call this D. Get the normalized delta vector of points B and C, call this E. You need to get a vector that’s perpendicular to E, which we’ll call F. To do this, you can say (in C#):

Vector2 F = new Vector2( E.y, -E.x );

Finally, dot D and F. If the result is consistently greater than 0 within some threshold, xor consistently less than 0 within some threshold, and you have met a minimum distance away from your start point, and are now within a threshold of your start point, then you have logged a circle-like gesture.

There are variations to this, but I think the general idea is presented.

As far as general gesture tracking, in case you’re not already up to speed, I’ll leave that to the existing answers and tutorials on that topic. Again, I’ve not done this, so I cannot recommend a good place for that information.

You can store multiple points during the touch start and touch end store them in an array. Now take the mean position of all the points and calculate the distance of all the points from that mean position, find mean of distance, if the variance or standard deviation of distance is low it means that you have a circle drawn by the user.
Its a naive method but worth a try. Also this method can give you an approximate of size of circle. You can set the threshold variance by training your algorithm or by using hit and trial.