[postgis-users] Angle between three points
Mike Toews
mwtoews at gmail.com
Fri Sep 17 12:27:39 PDT 2010
On 17 September 2010 10:51, Carlos Eduardo <carlospauluk at gmail.com> wrote:
> So, the logic that I thinked was to get three of the points of the polygon,
> and taking the middle point as the origin point, and the two others to
> make the lines, and then calc the angle between this two lines. if it is close to 180 degrees,
> i can remove the middle point.
I wouldn't be too sure about that. Just because there are three points
in lat/long with 180 degrees apart does not mean that it is a straight
line when projected (e.g., in Google Maps). The distortion increases
when you get near the poles, and when you have large polygons/lines.
It all depends on how the great circles are used/interpreted since
lat/long is _not_ Cartesian, unless you are in a small region near the
equator.
To get to your base question, you can determine the angle of two
points with ST_Azimuth(pointA, pointB). So you can use this function
with some vector math to get the angle between three points. Also, try
ST_Simplify(geomA, tolerance) to see if it does what you are trying to
accomplish. It will probably be easier than reinventing the wheel.
-Mike
More information about the postgis-users
mailing list