Calculate distance between two Latitudes and two Longitudes separately
I'm struggling to find out how to calculate the distances between two Latitudes and two Longitudes separately.
What I'm trying to do is the following:
I have n-Locations that define a contour of a real building of which I calculate the mid-point and now want to translate this contour into a virtual coordinate system based on the previous mentioned mid-point. The mid-point will be the origin of the virtual coordinate system and therefore I have to translate every contour Location relative to it. I was thinking of calculating the distance of each contour Location axis separately in relation to the mid-point and then use them as their new virtual positions.
Any hints of how I could calculate that?
Thanks in advance!
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).