Beispiel #1
0
 public TurtlePosition RestoreAngle()
 {
     if (_savedPositions.Count > 0)
     {
         return(_curPos = _savedPositions.Pop());
     }
     throw new IndexOutOfRangeException("Position stack is empty");
 }
Beispiel #2
0
        public TurtlePosition Forward(double len = 5.0)
        {
            var    angleRad = Math.PI * (_curPos.Angle / 180.0);
            double x        = _curPos.Point.X + Math.Cos(angleRad) * len;
            double y        = _curPos.Point.Y + Math.Sin(angleRad) * len;

            _curPos = new TurtlePosition(new Point(x, y), _curPos.Angle);
            return(_curPos);
        }
Beispiel #3
0
 public void Turn(double angle)
 {
     _curPos = new TurtlePosition(_curPos.Point, _curPos.Angle + angle);
 }
Beispiel #4
0
 internal Turtle(Point startPoint, double currentAngle = 0.0)
 {
     _curPos = new TurtlePosition(startPoint, currentAngle);
 }