0
$\begingroup$

i am developing an application for iPhone, and i need some help to solve this difficult problem.

I am working with the device compass, from where i get the angle where the iPhone is oriented.

I need to check what points are on a angle view(oriented with the compass) from the current location.

diagram

I have no idea how to make it, i have been thinking all the afternoon. Any consideration is apreciated. Thanks!!!!

  • 0
    the points are coordinates on a map. The current Position is where the user is... What part is confused to you?? Thanks!!2011-02-14

2 Answers 2

2

So from the compass you have bearings that are the limits of visibility. In your figure they appear to be $k+20^{\circ}$ and $k-20^{\circ}$ Then take the difference in position between the phone and each point. You can feed this to the Atan2 function to get the bearing (remember to convert between degrees and radians). If it is in range, you are good.

  • 0
    Ross, please check my new answer!2011-02-15
0

I can't get it, i have do the following.

Point 1(current position): 36.837147 -2.469118

Point 2: 36.837437 -2.469040

Point 3: 36.837452 -2.469162

Point 4: 36.837547 -2.469532

The angle given by the iPhone is 155º.


What i do is:

float x1=point1.longitude;   float y1=point1.latitude; float x2=point2.longitude; float y2=point2.latitude;  float x = x2 - x1; float y = y2 - y1;  float angle = atan2(y, x); 

Then the result is:

Angle between:

P1, P2=1.307330

P1, P3=1.713568

P1, P4=2.372586


But... Now you say to substract from the phone angle the obtained angle.For the three cases, it is something like 154.xx.

What i'm doing wrong? The true situation says that the P2 and P3 are inside 20º, but not the P3.

Thank You!!!

  • 0
    155-75=80, 80 it's outside the angle view, right? But this is not possible, the P2 is inside the angle view. What calculation am i doing wrong? Thanks!!2011-02-15