0
$\begingroup$

I've been looking for an answer for a specific question, a part of my question maybe related to this: Calculate the angle of a vector in compass (360) direction

However, my question is more specific, I am making a program for a dish to automatically move right and left based on the coordinates of an RC car (or plane) which are being transmitted to the program and this program will use the coordinates to be moving the dish keeping it pointed at the object(i.e. RC). I am working with decimals only for simplicity as for instance (30.894722, -97.900556)

What I am really looking for here is a relation, a mathematical relation where I can plug in the coordinates into the function and get something useful which I can use to direct the dish, I thought I would do this using an advanced algorithm but, a mathematical equation would be very helpful, useful and easier.

$\endgroup$

1 Answer 1

0
$\begingroup$

Edit: Attempted reunderstanding.

I assume you have two points on the surface of the earth. The first point is the satellite dish. The second point is the vehicle, which the dish must track.

If the longitudes and latitudes of the points are called $(\lambda_1, \varphi_1)$ for the dish and $(\lambda_2, \varphi_2)$ for the vehicle, then according to this website (http://www.movable-type.co.uk/scripts/latlong.html#bearing), you can compute your initial bearing $\theta$ (the angle you'd like) using the formula:

$$\theta = \text{atan2}{\left(\sin{( \lambda_2 - \lambda_1)} \cdot \cos{\varphi_2},\quad\cos{\varphi_1}\cdot\sin{\varphi_2}-\sin{\varphi_1}\cdot\cos{\varphi_2}\cdot \cos{(\lambda_2-\lambda_1)}\right)}$$

So $\lambda$ represents your longitude, $\varphi$ represents your latitude, and $\theta$ represents the angle you're interested in.


It's not exactly clear to me what your situation is based on your question, so feel free to clarify. But here is what I think you're saying:

You have a two dimensional problem viewed from above. A vehicle is moving around the coordinate plane, and there is a dish at the origin (or wherever) which must continue to point at the vehicle.

In this setup, if you know exactly the coordinates $(x,y)$ where the vehicle is sitting still and you assume that the dish is at the origin, you can use:

$$\theta = \arctan{(y/x)}$$

to find the proper angle for tracking the vehicle. Because of symmetry, the arctan function may get the wrong quadrant— but many programming languages supply a function "arctan2" (or atan2) which allows you to get an angle in the right quadrant.

If you need to predict the future location of the vehicle so that you can turn there in advance, that is also possible by measuring the vehicle's location at two different moments then extrapolating.

$\endgroup$
11
  • $\begingroup$ Also: Many programming languages call this "atan2" rather than "arctan2". $\endgroup$ Commented Jul 17, 2016 at 3:42
  • $\begingroup$ @JohnHughes, Amended! $\endgroup$
    – user326210
    Commented Jul 17, 2016 at 3:44
  • $\begingroup$ @user326210 thanks for the answer, also iam not sure if you know about this but, in earth coordinates like the one i provided, is the lat. (the first one) is considered as the x or y? $\endgroup$
    – aero
    Commented Jul 17, 2016 at 3:53
  • $\begingroup$ @aero Oh! I missed that you were using latitude and longitude. I should change my answer to help. Can you explain your situation more? Where is the dish located? $\endgroup$
    – user326210
    Commented Jul 17, 2016 at 3:57
  • $\begingroup$ ok, so the dish is not necessarily going to be at the origin, and it will only have to move 180 degrees not 360, that means the object will not get behind the dish, always in front of it, so that it (180 degrees), first i though that all i need to consider is the lat. and ignore the long(assuming the dish is pointed at west, all i need to know is the lat. which is how far north or south it is) but then i found out that i was wrong, i have to consider both to get it right, so the point is, for simplicity, i will only consider 180 degrees movement not 360 to avoid quadrant errors. $\endgroup$
    – aero
    Commented Jul 17, 2016 at 4:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .