public void TurnRight() { currentDirection = currentDirection.MinusRadians(radianRotation); }
private void MoveRover(Vector futurePosition) { var nextPosition = WrapAroundAxisIfNeeded(futurePosition); if (NextPositionIsBlockedByObstacle(nextPosition)) { IsObstructed = true; Obstruction = nextPosition; } else { currentPoint = nextPosition; } }
public void MoveForward() { var futurePosition = new Vector(currentPoint.X, currentPoint.Y); futurePosition += currentDirection; MoveRover(futurePosition); }
public void TurnLeft() { currentDirection = currentDirection.PlusRadians(radianRotation); }
public Rover(Point point, Char direction, Planet planet) { currentPoint = new Vector(point.X, point.Y); currentDirection = InitializeDirection(direction); this.planet = planet; }
private Vector WrapAroundAxisIfNeeded(Vector futurePoint) { if (futurePoint.X > planet.PositiveBorder) futurePoint.X = planet.NegativeBorder; else if (futurePoint.X < planet.NegativeBorder) futurePoint.X = planet.PositiveBorder; if (futurePoint.Y > planet.PositiveBorder) futurePoint.Y = planet.NegativeBorder; else if (futurePoint.Y < planet.NegativeBorder) futurePoint.Y = planet.PositiveBorder; return futurePoint; }
private Boolean NextPositionIsBlockedByObstacle(Vector nextPosition) { return planet.Obstacles.Any(o => o.X == nextPosition.X && o.Y == nextPosition.Y); }
private Boolean Equals(Vector other) { return this.X == other.X && this.Y == other.Y; }
private Vector CreateAndNormalizeVectorFor(double result) { var diffVector = new Vector((Int32)Math.Cos(result), (Int32)Math.Sin(result)); diffVector.Normalize(); return diffVector; }