Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determine of a coordinate is in a quadrilatera 1

Status
Not open for further replies.

kirkhettfield

Programmer
Apr 21, 2009
3
BE
Hi

I have a problem ( i'm stuck for a few days now) My problem is that I must determine of a coordinate is in a quadrilateral.
To put it simple, I get a coordinate from my GPS and i want to know if I'm on my property.

Does anyone has an idea how to program this? I thought about it a lot and I don't see a simple solution.

Thanks in advance.
 
this is a math problem. Once you have the math the code is simple. You have a point X. you also have some information to define the area
as an examples:
triangle:
length of 2 sides and an angle
2 angles and the length of one side
square:
length of 1 side
rectangle:
height and width
circle:
something to do with radius or diameter
polygon:
a level of math I don't have :)

you would also have point(s) to define where the area is located. finally, ask the polygon if the point is contained within its area.

some design concepts I could see in play.
1. Point is an immutable value object.
2. Polygon would be an interface/abstract class for all shapes.
3. You may have specific shapes like rectangle, square, circle to simplify the math or be explict about the shape.
4. Polygon seems like a good candidate for the fly weight pattern (not that a pattern should be used "just because")
5. Polygon may also be an immutable value object.

I know these are very high level ideas, but it's the math that you and I are stuck on.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Get the lat / lon of the "corners" of the property. Check GPS lat lon to see if they re within the min/max of the porperty lat lon figures. If the property is 'mor-or-less' a rectangle, that should do it, otherwise delve deeper, but use the sam approach - just slice the property into smaller chunks until you have 'regular' figures (rectangles or perhaps triangles).




MichaelRed


 
great idea, break the area in simple, common shapes, rather than mess with calculus :)

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
yes, but then that is (at least one concept in) calculs ... generally used to calculate the area of irregular shapes




MichaelRed


 
nice find. I think the naming convention an argument explosion is horrendous, but a little refactoring can fix that.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top