Example #1
0
        private void _UpdatePosition(long elapsed)
        {
            // Change of speed by 10km/h per second
            // Change of angle by 45 deg per second

            if (Accelerate)
            {
                TargetSpeed += 10.0 * elapsed / 1000.0;
            }
            if (Decelerate)
            {
                TargetSpeed -= Math.Min(10.0 * elapsed / 1000.0, TargetSpeed); // Prevents target speed to go below 0.
            }
            if (TurnLeft)
            {
                Angle = Angles.ClampDeg(Angle + elapsed * 45.0 / 1000.0);
            }
            if (TurnRight)
            {
                Angle = Angles.ClampDeg(Angle - elapsed * 45.0 / 1000.0);
            }

            _UpdateSpeed(elapsed);

            double angle = Angles.ToRadian(Angle);

            Position = Position.AddEnu(new Enu(Speed * Math.Cos(angle) * elapsed / 3600.0, Speed * elapsed / 3600.0 * Math.Sin(angle), 0));

            Elapsed += elapsed;
        }
Example #2
0
 public MotionModel(RemoteSimulator simulator, double latDeg, double lonDeg)
 {
     _simulator        = simulator;
     _timer            = new MyTimer(_TimerTick, new TimeSpan(0, 0, 0, 0, 10));
     _timer.Exception += _timer_Exception;
     _position.Lat     = Angles.ToRadian(latDeg);
     _position.Lon     = Angles.ToRadian(lonDeg);
 }