How to detect circle motion using UIGestureRecognizer

I want to see someone draw a circular motion on the screen with their finger - as if they are drawing an β€œO”. Is this possible with UIGestureRecognizer?

+4
source share
6 answers

My answer to my question:

I used this: http://iphonedevelopment.blogspot.com/2009/04/detecting-circle-gesture.html

.. but turned CircleView into a custom UIGestureRecognizer. Everything is beautiful.

+1
source

I think the answer to this depends on your definition of circular motion and how you intend to use it. For example, do you want to know how many degrees the user’s finger passes in a circle? Or, do you only care about completing the circle? What is the degree of accuracy you require? Do you want the movement to be interrupted, or should it be more than touching> drawing a circle> (for example, one movement)?

One approach would be to define a bundle of rectangular zones along a circle and detect if the user touches them sequentially. This can give you direction and a rough indication of the angle.

Another approach is to keep the points between touching and touching up, and also filter and fit the curve to find out which shape is approximated by the points. First low-pass filter using a basic FIR filter, and then look at dx and dy from point to point. A circle (like a series of arcs) must be within a certain range of changes in the slope from point to point, otherwise you have a different shape.

Another approach is to use a neural network to take points and tell you what the shape looks like.

+4
source
+2
source

Instead of using a gesture recognizer, this project responds to circular movements that track the angle of UITouch events.

+1
source

No, he does not recognize circular motion. To do this, you must implement your own method.

0
source

Here's how I needed to do this using callbacks in my view controller, but that could also be done in a gesture. Notice, I tried to detect several circular motions (2 or more circles clockwise or counterclockwise made during a touch event.

  • Store Touch CGPoints Models in an Array.
  • Create min / max rect of all points in your story array.
  • Divide this min / max rect into 4 smaller rectangles.
  • Assign each story point to a quadrant using CGRectContainsPoint () for each of the four quadrants.
  • Clockwise movement will have ascending quadrants. Movement counterclockwise will reduce the quadrants.
  • Check the width / height ratio if you want to detect circles against ovals
0
source

All Articles