Answer the question
In order to leave comments, you need to log in
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.
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
In the screenshot, the line formed by these 2 points is circled.
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; }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question