Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-12-2014, 10:29 PM
|
#1
|
LQ Newbie
Registered: Jan 2014
Posts: 3
Rep: 
|
Geofence algorithm and C logic
Hi all,
I am trying to find out circular and rectangular geofence logic in C.
(For circle, I will have fixed radius and centre coordinate)
Please help me with some links/suggestions/replies.
Thanks,
Tapas
|
|
|
02-14-2014, 09:29 AM
|
#2
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,955
|
What do you need to do, compute perimeter and area? Render the area on a map? Or determine coordinates which define a geometric shape?
If you have the coordinates for say a circle's center or the vertex's of a polygon, you're best first step is to convert those coordinates to decimal degrees and fractions of degrees. From there determine the conversion from the significant value of a GPS digit into distance. Then it's geometry calculations.
Example: Circle
You have center point. You know the radius. Due North, South, East, or West are simple additions or subtractions to either Latitude or Longitude starting from that center point. The 45's NE, SE, NW, SW can be found by using the sine or cosine functions. In the case of the 45, they're equal. To get different angles around the circle, follow the same method. From there you know how to calculate the coordinates by adding/subtracting to both lat and long. In fact for the circle, you only have to do 1/8th of it. Why? You know the zero degree deflection, you calculate the 45 degree deflection. Then if you want say every 5 degrees, you use sine and cosine to determine the X-Y offsets from your center point. Then to get the 45-90 chunk you swap the X-Y values you already calculated. For the other quadrants, you swap the signs. So by calculating 7 triangles, you can compute coordinates for a circle to the precision of 5 degree increments.
|
|
1 members found this post helpful.
|
02-16-2014, 11:47 PM
|
#3
|
LQ Newbie
Registered: Jan 2014
Posts: 3
Original Poster
Rep: 
|
Thanks ...
So, for a static circlular fence I can check/compute the coordinates with precision of 5 degrees (lets say). Then I can capture those points for evalutating individually with the current location of the subject.
So it is virtually a circle but can be told as a polygon sets of points, right?
|
|
|
02-17-2014, 06:36 AM
|
#4
|
Moderator
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,955
|
Quote:
Originally Posted by tapas bhoi
Thanks ...
So, for a static circlular fence I can check/compute the coordinates with precision of 5 degrees (lets say). Then I can capture those points for evalutating individually with the current location of the subject.
So it is virtually a circle but can be told as a polygon sets of points, right?
|
Yes, and really all circles can be considered a polygon of multiple points.
|
|
|
All times are GMT -5. The time now is 02:38 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|