Let's say I have a 4 by 4 maze as shown below, and I've written a program that returns a possible path from start to finish as shown below:
[(3, 1), (3, 0), (2, 0), (3, 0), (3, 1), (3, 2), (2, 2), (2, 3), (1, 3), (1, 2), (0, 2), (1, 2), (1, 1), (1, 0), (0, 0), (0, 1)]
The start point is the first element, and the end point is the last element.
How could I add a third value to each of the tuple containing a rotation in degrees in increments of 90? If a rotation occurred, it should return the rotation, and direction, with - indicating a counter-clockwise turn. Assume you start facing north.
For example, for the first two points,
[(3, 1), (3, 0), ... ]
it should return,
[(3, 1, -90), (3, 0, 90), ... ]
as on (3, 1) you must turn to face west in order to move onto the next point, and on (3, 0) you must turn to face north to move onto the third point.
For a set of points where no rotation would occur, and a 180 degree rotation would occur,
[ ... (0, 2, 180), (1, 2, 90), (1, 1, 0), (1, 0, 90), ... ]
as at (0, 2) you need to turn from facing north to facing south in order to move on, and for (1, 1) you are already facing the right direction.

To add a third value to each tuple containing a rotation in degrees in increments of 90, you can use the following Python code:
Output of the code: [[3, 1, -90.0], [3, 0, 90.0], [2, 0, 180.0], [3, 0, -90.0], [3, 1, -0.0], [3, 2, -90.0], [2, 2, 90.0], [2, 3, -90.0], [1, 3, -90.0], [1, 2, 90.0], [0, 2, 180.0], [1, 2, 90.0], [1, 1, -0.0], [1, 0, 90.0], [0, 0, 90.0]]
This code will take a list of points as input, where each point is represented as [x, y]. It calculates the rotation angle between consecutive points and appends the angle to each tuple in the format [x, y, rotation_angle]. The rotation_angle is in increments of 90 degrees, with a negative sign (-) indicating a counter-clockwise turn.