On Jan 17, 7:10 am, Nishant <[email protected]> wrote: > You have the center lat/long, height and width (in meters) of a > rectange. > how can I calculate the corners of the rectangle,
You don't say how large the rectangle is. For small rectangles, you can use plane geometry (eg Pythagoras' theorem) to calculate the diagonal from the centre to the corners; the bearing of the corner points from the centre can be calculated using trigonometry (theta=atan(height/width)). Then use the haversine formula to calculate the coordinates of the corners from the diagonal length and the bearing. See http://www.movable-type.co.uk/scripts/latlong.html -- scroll down to "Destination point given distance and bearing from start point" For large rectangles, or for a general solution, plane geometry won't work. You need multiple application of the haversine formula to find the points which are half the height of the rectangle from the centre point, directly north and south (that's a bearing of 0 and 180, and gives the northern and southern latitudes); and the points which are half the width of the rectangle from the centre point on the same latitude (bearings of 90 and 270 give the east and west longitudes). You can then get the coordinates of the corners from combining those figures. The general solution will produce a rectangle whose opposite sides are the same length. But when plotted on the map, it may not look like a rectangle because the projection will stretch the side nearest the pole. Andrew --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
