I
I
Ingvar Von Bjork2018-10-01 10:19:29
JavaScript
Ingvar Von Bjork, 2018-10-01 10:19:29

Why is the angle of inclination of a straight line incorrectly determined?

On Yandex.Maps, I draw a polygon using several points. The polygon boundaries need to be shifted by 30 meters. To do this, I take the two nearest points and determine their angle with respect to the X axis, add 90 degrees to this angle and put a point at a distance of 30 meters using solveDirectProblem() from the Yandex.Maps API. But the problem is that the angle is determined incorrectly.
For example:
2 coordinates are given: A = [64.364552, 41.057315] and B = [64.364229, 41.055964]. The angle is calculated as Math.atan2(41.057315 - 41.055964, 64.364552 - 64.364229). I get the answer in radians: 1.3361193770989723 or about 76 degrees. Although the eye here comes out about 45 degrees.
In the screenshot, the line formed by these 2 points is circled.
qcmIa.jpg
A specific example can be found here. Select the Municipal Formation "Bobrovo-Lyavlenskoye" => GBSU JSC "Trepuzov Psychoneurological Boarding School". There is a small log in the console.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Skusnov, 2018-10-01
@DeboshiR

In the screenshot, the line formed by these 2 points is circled.

Ruler tool: height change 40 m, length 64 m. Ratio 0.625, arc tangent 35 degrees.

D
d0lph1n, 2018-10-13
@d0lph1n

Because projections are used in cartography. If you try to draw a geometric figure (a house, for example) only in coordinates, everything will be displayed as it should in the equator region, but the closer we move to the poles, the more our picture "flattens" vertically. You have 60th latitude, which means about 2x flattening.
I give a code snippet to correct taking into account the proportions:

RAD2DEG = 180 / Math.PI;
PI_4 = Math.PI / 4;

/* The following functions take or return their results in degrees */

function y2lat(y) { return (Math.atan(Math.exp(y / RAD2DEG)) / PI_4 - 1) * 90; }
function x2lon(x) { return x; }

function lat2y(lat) { return Math.log(Math.tan((lat / 90 + 1) * PI_4 )) * RAD2DEG; }
function lon2y(lon) { return lon; }

Source
If you want proportionality - transform the coordinates with lat2y and lon2x and calculate based on what happened during the transformation.

K
Karpion, 2018-12-08
@Karpion

It seems to me that Yandex.Maps uses such a projection so that the displayed area is not distorted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question