Try this problem on for size.
It's geometry! It's fun.
I need an algorithm to "multiply" (expand) a polygon. A 2x multiplier will actually expand the "radius" (for lack of a better word) by 2x, so the surface area will increase obviously more than 2x. That's fine.
The polygon is defined as a set of geographical points (lat, long) overlayed on a map.
My current thought is to calculate the centroid of the polygon (which I've already, quite awesomely, done) and then construct a right-angle triangle with the centroid, the point I want to expand, and a new imaginary point that takes the x from the centroid and the y from the point I want to expand.
Then I could multiply the hypotenuse and leverage SOHCAHTOA and all that fun **** to derive the other x, y offset values for the new points. I did this, quite awesomely, but then I realized this wasn't working because I was using algorithms to determine the length of the triangle sides using KILOMETERS when the points are defined as COORDINATES.
So I'm stuck at this point. I'm trying to devise a way to calculate the new point position for each point of a polygon relative to the centroid given a multiplication factor.
I'd like to find a way to determine the lat/long of a point given the centroid, the angle in radians, and distance (in either kilometers or coordinate "units").
The approach I'm going to take tomorrow morning is to simply determine the length in coordinate "units" of the hypotenuse, which I've already determined like so:
where lat1/lon1 and lat2/lon2 are the lat/long of the centroid and original point location, respectively.
I'll then multiply that number by my multiplier, then use trig to solve for the new x,y (lat/lon) offsets.
Does this make any sense to anyone?
It's geometry! It's fun.
I need an algorithm to "multiply" (expand) a polygon. A 2x multiplier will actually expand the "radius" (for lack of a better word) by 2x, so the surface area will increase obviously more than 2x. That's fine.
The polygon is defined as a set of geographical points (lat, long) overlayed on a map.
My current thought is to calculate the centroid of the polygon (which I've already, quite awesomely, done) and then construct a right-angle triangle with the centroid, the point I want to expand, and a new imaginary point that takes the x from the centroid and the y from the point I want to expand.
Then I could multiply the hypotenuse and leverage SOHCAHTOA and all that fun **** to derive the other x, y offset values for the new points. I did this, quite awesomely, but then I realized this wasn't working because I was using algorithms to determine the length of the triangle sides using KILOMETERS when the points are defined as COORDINATES.
So I'm stuck at this point. I'm trying to devise a way to calculate the new point position for each point of a polygon relative to the centroid given a multiplication factor.
I'd like to find a way to determine the lat/long of a point given the centroid, the angle in radians, and distance (in either kilometers or coordinate "units").
The approach I'm going to take tomorrow morning is to simply determine the length in coordinate "units" of the hypotenuse, which I've already determined like so:
Code:
d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))
I'll then multiply that number by my multiplier, then use trig to solve for the new x,y (lat/lon) offsets.
Does this make any sense to anyone?
Comment