Here is an idea of how you can optimize the code to run much faster.
instead of using the matrix multiplication that i wrote , you can use numpy arrays and numpy matmul.
and for a faster search you can try to implement a QuadTree for a quick spacial search... ✌