• Welcome! The TrekBBS is the number one place to chat about Star Trek with like-minded fans.
    If you are not already a member then please register an account and join in the discussion!

Question about trigonometry and lat/long coordinates

PlixTixiplik

Commodore
Commodore
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
 
Apply a transform. Calculate the offset needed, then "add" it to each point. This should "move" the polygon into 1 quadrant.

I'm sure there's a better way to do this, but it's simple.
 
If you are not already a member then please register an account and join in the discussion!

Sign up / Register


Back
Top