Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

How could you get the latitude and longitude of four points (equal distance apart) on a line from $(27,-82)$ to $(28,-81)$? The four points should split the line into 5 parts.

enter image description here

share|improve this question
add comment

4 Answers 4

up vote 1 down vote accepted

Given the latitudes of two points, $\beta_1$ and $\beta_2$, and their difference in longitude, $\Delta\lambda=\lambda_2-\lambda_1$, compute $\delta\in[0,\pi]$ with $$ \cos(\delta)=\sin(\beta_1)\sin(\beta_2)+\cos(\beta_1)\cos(\beta_2)\cos(\Delta\lambda)\tag{1} $$ Then compute $\alpha$ using $$ \tan(\alpha/2)=\frac{\sin(\Delta\lambda)\cos(\beta_1)\cos(\beta_2)}{\sin{\beta_2}-\sin(\delta-\beta_1)}\tag{2} $$

spherical triangles, honest

After computing $\delta$ and $\alpha$, compute $\beta'\in[-\frac{\pi}{2},\frac{\pi}{2}]$ with $$ \sin(\beta')=\sin(\beta_1)\cos(k\delta/5)+\cos(\beta_1)\sin(k\delta/5)\cos(\alpha)\tag{3} $$ Then compute $\Delta\lambda'=\lambda'-\lambda_1$ using $$ \tan(\Delta\lambda'/2)=\frac{\sin(k\delta/5)\sin(\alpha)\cos(\beta_1)}{\cos(k\delta/5)+\cos(\beta_1+\beta')}\tag{4} $$ Where $k$ in $(3)$ and $(4)$ ranges in $\{1,2,3,4\}$.

share|improve this answer
add comment

The simplest is to plot $(27,-82)$ and $(28,-81)$ on your map using whatever projection you have, split the difference in pixel count into five, and plot the points that produces. That will produce a straight line on your display, which may be what you want. If you want something else, you have to define what route you want. It could be a great circle, which is the shortest distance. It could be the rhumb line, which maintains a constant bearing. Or it could be some others.

share|improve this answer
    
I'm going to be using this to calculate points for the navigation of a Remote Control UAV. So it needs to be very accurate. –  AndrewFerrara Oct 21 '11 at 20:14
1  
If you are using it for waypoints, any points will work. If they are not on the great circle, you will follow a longer path, but will get there. If not, how are you using it? –  Ross Millikan Oct 21 '11 at 20:16
add comment

Is the answer not simply found by changing each coordinate each time by a fifth of the difference in each of the lat and long elements.

(27, -82) (27.2, -81.8) (27.4, -81.6) (27.6, -81.4) (27.8, -81.2) (28, -81)

share|improve this answer
    
That is a simple approximation and at this scale is probably good enough. If the start and finish points were much further apart it would be wrong as it does not take into account the curvature of the Earth: you would need to look at a great circle. –  Henry Oct 22 '11 at 9:19
add comment

You could proceed as follows:

  1. Compute the distance $D$ between the two lat/lng points $P_1, P_2$ along the great circle.

  2. Compute the heading (bearing) $h$ of the great circle through $P_1, P_2$.

  3. Compute any point $P$ on the great circle between the two lat/lng points $P_1, P_2$, given the heading $h$ and the distance $d$ between $P_1$ and $P$, e.g. $d(n)=n D/5, n = 1..4$, in your case.

You will find formulae for all these computations on the Web, e.g. in the very good page Calculate distance, bearing and more between Latitude/Longitude points by Chris Veness.

ADDITION. I see that you included a Google Maps example. If you use Google Maps API v3, then everything is very easy:

(0) Include the Geometry library into your Web page for Spherical Computations:

<script type="text/javascript" 
    src="http://maps.googleapis.com/maps/api/js?libraries=geometry&sensor=false">
    var g = google.maps.geometry.spherical; 
</script>

(1) Use var D = g.computeDistanceBetween(P1, P2); to compute the distance D between the two points.

(2) Use var heading = g.computeHeading(P1, P2); to compute the heading.

(3) Use var point = g.computeOffset(P1, D/5, heading); to compute the point at the distance D/5 from P1 along the great circle line P1 -> P2. Similarly for the other dividing points.

share|improve this answer
    
According to this calculator, the rhumb line and the great circle have the same length to the 0.1 km accuracy displayed (out of 150 km) and the bearing varies over the route by only 28 minutes on the great circle. On this scale, the earth is very close to flat. –  Ross Millikan Oct 22 '11 at 0:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.