Function fromDirection

A direction is stored as an array [0, 0, 0, 0, y, x, 0, 0] representing vector (x, y).