converting to global and local coordinates. kinda broken