/*
 public ParameterizedMousePosition(Position.IVirtualMousePosition mousePos, PointD newVirtualPosition, PointD newVelocity, PointD newAcceleration)
 {
     m_mouse = mousePos;
     m_newPosition = newVirtualPosition;
     m_newAcceleration = newAcceleration;
     m_newVelocity = newVelocity;
  * m_newDisplacement = m_mouse.GetDisplacement();
     m_fakeTime = mousePos.GetTimeInterval();
 }*/
 public ParameterizedMousePosition(Position.IVirtualMousePosition mousePos, PointD newVelocity, PointD newAcceleration)
 {
     m_mouse = mousePos;
     m_newPosition = mousePos.GetVirtualPointD();
     m_newAcceleration = newAcceleration;
     m_newVelocity = newVelocity;
     m_newDisplacement = m_mouse.GetDisplacement();
     m_fakeTime = mousePos.GetTimeInterval();
 }
 public ParameterizedMousePosition(Position.IVirtualMousePosition mousePos, int fakeTime)
 {
     m_mouse = mousePos;
     m_newPosition = mousePos.GetVirtualPointD();
     m_newAcceleration = mousePos.GetAcceleration();
     m_newVelocity = mousePos.GetVelocity();
     m_newDisplacement = m_mouse.GetDisplacement();
     m_fakeTime = fakeTime;
 }
        public override PointD GetVelocity(Position.IVirtualMousePosition m)
        {
            PointD normalVector;
            PointD nearPt;
            double radius;
            ExtendedNormalOfPoint(m.GetVirtualPointD(), out normalVector, out nearPt, out radius);

            PointD dir = PointD.Orthogonal(normalVector);
            PointD normalComponent = PointD.DotProduct(dir, m.GetVelocity()) * dir;
            PointD tangentComponent = m.GetVelocity() - normalComponent;

            return -1 * tangentComponent * m_Param.C;
        }
Beispiel #4
0
 public override PointD GetVelocity(Position.IVirtualMousePosition m)
 {
     // velocity restriction
     double speed = m.GetSpeed();
     double speedLimit = m_Param.C  * 10 * GetStrength(m.GetVirtualPointD());
     if (speed > speedLimit)
     {
         PointD maxParts = new PointD(speedLimit * m.GetUnitDirection().X, speedLimit * m.GetUnitDirection().Y);
         return -1 * m.GetVelocity() + maxParts;
     }
     else
     {
         return PointD.Empty;
     }
 }
 // called very frequently
 public void MouseMoved(Position.VirtualMousePosition mouseMove)
 {
     m_virtualDelta.Add(mouseMove.GetVirtualPointD() - mouseMove.GetLastVirtualPointD());
     m_realDelta.Add(new PointD (mouseMove.GetPhysicalPoint().X - mouseMove.GetLastPhysicalPoint().X,
                                 mouseMove.GetPhysicalPoint().Y - mouseMove.GetLastPhysicalPoint().Y));
     if (m_virtualDelta.Count > MouseLogger.TAIL_LENGTH)
     {
         // BUG: sometimes mouseMoved gets fired with no movement of the mouse,
         // flooding the event queue with many points of data estimated to be
         // > 40,000 points. Remove first half of the point data when such a
         // condition may occur.
         m_virtualDelta.RemoveRange(0, MouseLogger.TAIL_LENGTH / 2);
         m_realDelta.RemoveRange(0, MouseLogger.TAIL_LENGTH / 2);
     }
 }
 public override PointD GetVelocity(Position.IVirtualMousePosition m)
 {
     PointD orig = m.GetVelocity();
     return orig * (1 + m_Param.C) * GetStrength(m.GetVirtualPointD());
 }
        public void Compute(Position.IVirtualMousePosition mousePosition, out bool filtersChanged)
        {
            int i = 0;
            PointD sumVel = mousePosition.GetVelocity();
            PointD sumAccel = mousePosition.GetAcceleration();

            PointD displ = mousePosition.GetDisplacement();
            Position.ParameterizedMousePosition mp = new Position.ParameterizedMousePosition(mousePosition);

            int numInUse = 0;// instrumentation
            filtersChanged = false; // flag out if filter state changes

            for (i = 0; i < m_Filters.Count; i++)
            {
                if (m_Filters[i].Parameters.FilterEnabled )
                {
                    if (m_Filters[i].HitTest(mousePosition.GetVirtualPointD()))
                    {
                        if (!m_Filters[i].Parameters.InUse)
                            m_Filters[i].Parameters.UseCounter++;

                        if (!m_Filters[i].Parameters.InUse)
                            filtersChanged = true;

                        m_Filters[i].Parameters.InUse = true;
                        numInUse++;// instrumentation

                        PointD vel = m_Filters[i].GetVelocity(mp);
                        if (!(double.IsNaN(vel.X) || double.IsInfinity(vel.X)
                            || double.IsNaN(vel.Y) || double.IsNaN(vel.Y)))
                        {
                            sumVel += vel;
                            mp.SetVelocity(sumVel);
                        }

                    }
                    else
                    {
                        if (m_Filters[i].Parameters.InUse)
                            filtersChanged = true;

                        m_Filters[i].Parameters.InUse = false;
                    }
                }
            }
            m_maxNumInUse = Math.Max(numInUse, m_maxNumInUse); // instrumentation
            m_computedAcceleration = sumAccel;
            m_computedVelocity = sumVel;
        }