Calculate all mid points of a line at a given interval

In summary, The conversation discusses using Google maps coordinates to divide a line into segments of equal length, with the unit of measure being meters. The formula used for this purpose is (x2-x1)/distance and (xy-xy)/distance. However, since latitude and longitude are points on the surface of a sphere, this formula may not be accurate. Instead, the conversation suggests using a spherical model with a radius of 6353 meters. To calculate the points every 1 meter, the formula (d.lat/12.703) and (d.long/12.703) is used to divide the line into 12.703 pieces.
  • #1
Rich2020
4
0
Hi guys & girls, I'm using Google maps coordinates to draw a line and want to divide the line by its length, giving segments where the length of each segment is equal to 1.

EG:

P1
p1.lat = 54.97435323116719
p1.lng = 54.9742647135445

P2
p2.lat = -1.6116368025541306
p2.lng = -1.6115100681781769

let's assume that the unit of measure is meter.

Now, between the points p1 and p2, I need to calculate the (x,y) every 1 meter - along the length of the line.

My attempt results in:
x = -0.000006809047899462957, y = 0.00000974879815028264

but I'm not sure if that is correct.

I use the formula:
x = (x2-x1) / distance
y = (xy-xy) / distance

Is this correct? If not, how can I do this?
 
Mathematics news on Phys.org
  • #2
The formula you used is for the distance between points in a pane - latitude and longitude are points on the surface of a sphere. The distance between the two points is the curved distance across the surface of the Earth.
 
  • #3
Rich2020 said:
P1
p1.lat = 54.97435323116719
p1.lng = 54.9742647135445

P2
p2.lat = -1.6116368025541306
p2.lng = -1.6115100681781769
I'm guessing that you meant:
P1
p1.lat = 54.97435323116719
p1.long = -1.6116368025541306

P2
p2.lat = 54.9742647135445
p2.long = -1.6115100681781769

These are points near New Castle, England. These points are only about 10 meters apart and not too close to the North or south poles. So, unless we're sticklers for precision, we won't need to deal with spherical geometry and great circle distances.

Another approximation we will use is the shape of the Earth. We will assume a sphere of radius 6353 meters.

So, with this model:

1 degree of latitude = 2 pi R / 360 = (2 · 3.1416 · 6353 / 360) KM
= 110.881 Km

1 degree of longitude = 2 pi R cos(lat) / 360 = cos(54.974°) · 110.88 KM = 0.573944 · 110.88 KM
= 63.639 Km

Our deltas are P2-P1:
D
d.lat = 54.9742647135445 - 54.97435323116719 = -0.00008851762269
d.long = -1.6115100681781769 - -1.6116368025541306 = 0.0001267343759537

The length of D will be about:
√ ( (d.lat*110.881)² + (d.long*63.639)² ) Km = √161.3809 m
= 12.703 meters

So we need to divide D into 12.703 pieces, although you may want to round to 13:
S = D/12.703
S.lat = D.lat/12.703 = -.0000069679°
S.long = D.long/12.703 = .0000099762°

S is a step value, so the points will be P1 + nS where n=1, 2, ... 12.
 
  • Like
Likes 1 person
  • #4
Thanks so much! Here is a link to the results in action: http://jsfiddle.net/FPby3/

I still need to tweek it a little but it's doing what I need so thank you very much! I shall name the marker array after you!
 
  • #5
Rich2020 said:
I shall name the marker array after you!
I am honored!
 

1. How do I calculate the mid points of a line at a given interval?

To calculate the mid points of a line at a given interval, you will need to first determine the length of the line and the desired interval. Then, divide the length by the interval to find the number of segments. Finally, use the formula (x1+x2)/2 and (y1+y2)/2 to find the mid points for each segment.

2. What is the purpose of calculating mid points of a line at a given interval?

The purpose of calculating mid points of a line at a given interval is to accurately divide the line into smaller segments. This can be useful for tasks such as creating a graph or analyzing data that is spread out along a line.

3. Can I use any formula to calculate the mid points of a line at a given interval?

Yes, there are several formulas that can be used to calculate mid points at a given interval. The most commonly used formula is (x1+x2)/2 and (y1+y2)/2, but there are also other formulas that can be used depending on the specific scenario and data being analyzed.

4. Is it necessary to have a specific interval in order to calculate mid points of a line?

No, it is not necessary to have a specific interval in order to calculate mid points of a line. However, having a set interval can make the calculations more accurate and organized, especially if the line is long and has many data points.

5. Are there any limitations to calculating mid points of a line at a given interval?

There are a few limitations to calculating mid points of a line at a given interval. One limitation is that the intervals must be evenly spaced in order for the calculations to be accurate. Additionally, the accuracy of the calculations may also depend on the precision of the data points used.

Similar threads

  • General Math
Replies
3
Views
874
Replies
9
Views
16K
Replies
13
Views
3K
  • General Math
Replies
1
Views
4K
Replies
17
Views
4K
Replies
4
Views
2K
Replies
3
Views
2K
  • Precalculus Mathematics Homework Help
Replies
7
Views
874
  • General Math
Replies
1
Views
2K
Replies
2
Views
1K
Back
Top