LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I determine if a gps coordinate is within a box formed by 4 other gps locations?

I am writing a routine for a tractor equiped with gps. Given a set of gps coordinates marking boundries for multiple plots within a field which the tractor is to operate, how do I determine which plot the tractor is currently in? The plots are not oriented North-South so I need a quick lesson in geometry.
 
0 Kudos
Message 1 of 4
(5,230 Views)

It's been a while since I've had to think about these math/geometry type problems.  Here is an idea.

You know the 4 GPS locations and their X Y coordinates.  Call them A, B, C, D.  Calculate the area of the quadrilateral.  Assume A, B, C, D are labelled clockwise, and they are a convex quad, but don't have to be a square, rectangle, parallelogram ....  You can calculate the area by summing the area of triangle A, B, and C and triangle BCD.  You can google to find some methods to do this.

You have your point of interest, call it P.  Calculate the area of the triangle between it and each of the 4 sides.  So triangle PAB, PBC, PCD, and PDA.

If P is inside of Quad ABCD, then the sum of those 4 triangular areas would equal the area of the quad.

If P is outside the quadrilateral, then the sum of the areas would have to be greater than the area of the quadrilateral because the 4 triangles would all encompass area that is outside of the quadrilateral.



Message Edited by Ravens Fan on 02-06-2008 10:49 PM
0 Kudos
Message 2 of 4
(5,217 Views)
I find Dan Sunday's website very helpful for these type of geometry problems:

http://softsurfer.com/algorithm_archive.htm
0 Kudos
Message 3 of 4
(5,210 Views)
Although not a direct answer to your question, I posted GPS stuff here a while back.  They should help you out.
0 Kudos
Message 4 of 4
(4,960 Views)