The Doctor, in trying to escape from the Dalek forces has decided to send them in a spin by traveling in various pockets of space in a spiral motion.
Depending on the nature of the available space-time, The Doctor needs to enter into the TARDIS controls the height and width of the section of space and his entry point with which to begin the spiral.
The section of space can be envisioned as a h x w grid filled with sequential integers from left to right, top to bottom, starting with 1.
The starting position is provided as r c for the row and column... From this the TARDIS's software needs to spit out the ordered list of integers obtained by spiraling outward in an anti-clockwise direction from row r column c, starting upwards...
Your task, as the Doctor's companion is to program the TARDIS to take four numbers, in the format height width row column
and have it determine which sector of space the TARDIS needs to travel to match the spiral movement described below...
Input 1
5 5 3 3
(5 x 5 grid, starting at position 3,3)
Output 1
13 8 7 12 17 18 19 14 9 4 3 2 1 6 11 16 21 22 23 24 25 20 15 10 5
Explaining output
Original grid
Generated spiral
Input 2
2 4 1 2
(2 x 4 grid starting at position 1,2)
Output 2
2 1 5 6 7 3 8 4
Explaining output
Slightly different as spiral now must circle around grid to generate respective output...
Original grid
Generated spiral
Rules:
This is code-golf, so shortest code length gets the tick of approval.
The above examples must be used to test your code. If it doesn't provide the respective output, there's something wrong...
Both golfed and in-golfed versions of code must be provided in your answer...
Good luck!