Esempio n. 1
0
        // Update the segment's position and compute a smoothed velocity for the circle or the
        // endpoints of the segment based on  the time it took it to move from the last position
        // to the current one.  The velocity is in pixels per second.
        public void UpdateSegment(Segment s)
        {
            LastSegment = Segment;
            Segment = s;
            // TODO check here
            DateTime cur = DateTime.Now;
            double fMs = cur.Subtract(TimeLastUpdated).TotalMilliseconds;
            if (fMs < 10.0)
            {
                fMs = 10.0;
            }

            double fps = 1000.0 / fMs;
            TimeLastUpdated = cur;

            if (Segment.IsCircle())
            {
                XVelocity = (XVelocity * Smoothing) + ((1.0 - Smoothing) * (Segment.X1 - LastSegment.X1) * fps);
                YVelocity = (YVelocity * Smoothing) + ((1.0 - Smoothing) * (Segment.Y1 - LastSegment.Y1) * fps);
            }
            else
            {
                XVelocity = (XVelocity * Smoothing) + ((1.0 - Smoothing) * (Segment.X1 - LastSegment.X1) * fps);
                YVelocity = (YVelocity * Smoothing) + ((1.0 - Smoothing) * (Segment.Y1 - LastSegment.Y1) * fps);
                XVelocity2 = (XVelocity2 * Smoothing) + ((1.0 - Smoothing) * (Segment.X2 - LastSegment.X2) * fps);
                YVelocity2 = (YVelocity2 * Smoothing) + ((1.0 - Smoothing) * (Segment.Y2 - LastSegment.Y2) * fps);
            }
        }
Esempio n. 2
0
 public BoneData(Segment s)
 {
     Segment = LastSegment = s;
     XVelocity = YVelocity = 0;
     XVelocity2 = YVelocity2 = 0;
     TimeLastUpdated = DateTime.Now;
 }