Coordinate conversion general function