Hopefully we've got some math types here, because I can't figure out the solution to this problem at all! I'm working on a script to calculate the geographic range of fossil species, given a set of occurrences (latitudes and longitudes). So far the script works really well in generating an n-sided polygon and from there it's easy enough to figure out the area (a function of the sum of the interior angles).
The problem is that in some cases the calculation of the interior angle doesn't work - especially where one of the points lies in a different quadrant from the others. For example, when 1 point is at greater than 90 degrees longitude and the other two are less than 90 degrees. It also crops up when one point has a negative latitude (south of the equator) and the other two are positive, and perhaps in other instances I haven't identified yet.
I'm pretty sure the problem lies somewhere in the arctangent and how it is expressed in those quadrants (I'm using atan2 but the problem persists), but I can't find anything online that pertains to this specific example of lat/long calculation. Does anyone have any ideas how to fix this problem?
-MEC
The problem is that in some cases the calculation of the interior angle doesn't work - especially where one of the points lies in a different quadrant from the others. For example, when 1 point is at greater than 90 degrees longitude and the other two are less than 90 degrees. It also crops up when one point has a negative latitude (south of the equator) and the other two are positive, and perhaps in other instances I haven't identified yet.
I'm pretty sure the problem lies somewhere in the arctangent and how it is expressed in those quadrants (I'm using atan2 but the problem persists), but I can't find anything online that pertains to this specific example of lat/long calculation. Does anyone have any ideas how to fix this problem?
-MEC