LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 02-12-2014, 11:29 PM   #1
tapas bhoi
LQ Newbie
 
Registered: Jan 2014
Posts: 3

Rep: Reputation: Disabled
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
 
Old 02-14-2014, 10:29 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,147
Blog Entries: 13

Rep: Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563
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.
Old 02-17-2014, 12:47 AM   #3
tapas bhoi
LQ Newbie
 
Registered: Jan 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
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?
 
Old 02-17-2014, 07:36 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,147
Blog Entries: 13

Rep: Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563Reputation: 3563
Quote:
Originally Posted by tapas bhoi View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LSI Logic / Symbios Logic 53c875 (rev 14) -> HP Storageworks 1/8 G2 gileravxr Linux - Hardware 0 07-21-2009 05:45 AM
token bucket algorithm vs Leaky bucket algorithm xeon123 Linux - Networking 2 03-26-2007 05:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration