0

Given

  • Line defined by two coordinates (latitude / longitude in decimal degrees) A and B
  • Offset / distance to the line in meters d

Wanted

  • Coordinates A1, A2, B1, B2 ("below" and "above") perpendicular to the line at a distance d for point A and B

enter image description here

What I have tried already

In a cartesian coordinate system, the calculation can be done easily, e.g. following How do you find a point at a given perpendicular distance from a line? given x1, x2, y1, y2 and N being the distance:

dx = x1-x2
dy = y1-y2
dist = sqrt(dx*dx + dy*dy)
dx /= dist
dy /= dist
x3 = x1 + (N/2)*dy
y3 = y1 - (N/2)*dx
x4 = x1 - (N/2)*dy
y4 = y1 + (N/2)*dx

What I have achieved

I have tried the above solution on pen & paper with coordinates like A (5/3) and B (10/4), the results were fine, the calculated points were on a perpendicular line.

Then, I have tried it with "real coordinates" (e.g. lat=52.50004577636719, lon=13.39927864074707) and I treated those coordinates as if they were normal 2D cartesian coordinates. The output is distorted -> the points are not on the perpendicular line.

enter image description here

Questions

  • When I assume that my coordinates are "cartesian" coordinates, then I get distorted results, e.g. when rendering those coordinates it appears to be not really perpendicular. Can I somehow get rid of this distortion?

  • Is "perpendicular to a line between two coordinates" defined at all when dealing with latitude / longitude values?

  • Is there a way to use the "cartesian method" and then map back to real latitude / longitude?

[EDIT] Solved by calculating the bearing:

https://stackoverflow.com/a/60550894/844416 https://www.movable-type.co.uk/scripts/latlong.html https://www.igismap.com/formula-to-find-bearing-or-heading-angle-between-two-points-latitude-longitude/

1awuesterose
  • 495
  • 5
  • 15

0 Answers0