Is there a method using numpy and matplotlib to move a unit forward when there's a 1 and rotate by 45 degrees when there's a 0? Based on the array, [0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1] create a graph starting from the coordinate (0, 0) and move ahead by one unit if there's a 1 and rotate by 45 degrees if you encounter 0.
I attempted this on a small scale but have got to nowhere.
from math import sin, cos, radians
def parse(lexemes):
current = [0, 0]
path = [current]
angle = 0 # In degrees
for lex in lexemes:
if not lex:
angle += radians(45)
else:
current[0] += cos(angle)
current[1] += sin(angle)
path.append(current)
return path
print(parse([0, 1, 1, 0, 1]))