Exemplo n.º 1
0
        public void ApplyPoint(PointF point)
        {
            var offset = point.Subtract(_startPoint);

            if (points.Count == 0)
            {
                points.Add(new GesturePoint { X = offset.X, Y = offset.Y, threshold = 10 });
            }
            else
            {
                var last = points.Last();
                var lastPoint = new PointF(last.X, last.Y);

                // first check distance from last point
                if (lastPoint.DistanceTo(offset) > 10)
                {
                    var currentAngle = _previousOffset.AngleTo(offset);
                    var previousAngle = lastPoint.AngleTo(_previousOffset);

                    var da = currentAngle - previousAngle;
                    if (da < -Math.PI) da += 2 * Math.PI;
                    if (da > Math.PI) da -= 2 * Math.PI;

                    if (da > 0.1)
                    {
                        AddPoint(_previousOffset);
                    }
                }
            }

            _previousOffset = offset;
        }