You can do what you want with less math of calculating the distance. Instead find the min and max for both the latitude and longitude of the building contour. This will be your bounding box.
To scale your X-axis: calculate distance between midpoint and min/max longitude at the same latitude as the mid-point. Scale the result accordingly (e.g., normalizing).
To scale your Y-axis: calculate distance between midpoint and min/max latitude at the same longitude as the mid-point. Scale the result accordingly (e.g., normalizing).