make bezier curve control points at right place on the map

邮差的信 提交于 2019-12-11 14:22:11

问题


I wanna draw a bezier curve between two location points. I can draw some curve following some answers on stackoverflow, but the point for bezier control points are placed wrong for some cases although I'm using the same simple formula for a bezier curve.

What I'm doing to put two bezier control points at right point, - make a line that is always supposed to cross the linear line between two locations orthogonally. - make two bezier control points(+ and -) that are in the middle of somewhere on the orthogonal line and each of two locations.

But for some cases(two locations are not located horizontal or vertical), the line doesn't go orthogonally like below since control point is not on the orthogonal line and I'm wondering if there is difference between latitudeDelta scale and longitudeDelta scale, which causes the problem, but not sure.

and my calculation looks like this.

    const slopeOfLinearLine = (destination.latitude - origin.latitude) / (destination.longitude - origin.longitude)
    const slopeOfOrthogonalLine = -1 / slopeOfLinearLine
    const x = some x value to move right or left.
    const y = slopeOfOrthogonalLine * x
    const topOfTriangle = { latitude: midLinearLine.latitude + y, longitude: midLinearLine.longitude + x }

Please let me know anyone has any idea about this issue. Thanks!


回答1:


Scale in km(miles) per degree is different for latitude and longitude, so for usually used projections scale differs by factor f=Cos(latitude), map is anisotropic.

So you can:

1) generate control points Bezier curve in screen coordinate system (pixels)
or
2) build correct middle perpendicular in Lat/Lon system using formulas from this page - find middle point at big circle arc, find bearing in that point, find perpendicular bearing, build point at some distance from middle at perpendicular bearing



来源:https://stackoverflow.com/questions/56237239/make-bezier-curve-control-points-at-right-place-on-the-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!