4 Replies Latest reply on Apr 2, 2007 7:27 AM by abeall

    Gesture/Pattern Recognition

    Rothrock Level 5
      I'm going through this excellent article about gesture recognition: http://www.gamedev.net/reference/articles/article2039.asp#

      It is working fairly well so far, but I'm only up to the part where it simplifies the drawn gesture.

      Basically you create an array of the points you draw (in my case with a mouse drag).

      Then to simplify the gesture you want to make some smaller number of evenly spaced points along that shape. So that you come out with, say 32 or some such number of points.

      The algorithm presented basically starts adding up the distances between each point and when it gets to a distance greater than or equal to 1/32 of the total length it copies that point into the new spaced array.

      This would work great if my original array had points that were spaced fairly consistently. But both with onMouseMove and onEnterFrame I get far to disparate spacing of my points. If I draw very slowly and carefully I get nice even spacing, but even a moderate mouse drag is not even.

      Anybody with me so far?

      I do know a brute force kind of solution and that would be to do some kind of average length for all the segments and then go through and split any overtly long lengths into to segments. It is just some trig and a splice.

      I'm just wondering if anybody has any other recommendations?

      You can see what it looks like with the attached code. Past it into a Frame action on frame 1. And have a small dot of one color set to export as dot and a small dot of another color set to export as oDot.