在地图上的正确位置制作贝塞尔曲线控制点 [英] make bezier curve control points at right place on the map

查看:303
本文介绍了在地图上的正确位置制作贝塞尔曲线控制点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在两个位置点之间绘制贝塞尔曲线. 我可以在有关stackoverflow的一些答案之后绘制一些曲线,但是在某些情况下,贝塞尔控制点的位置是错误的,尽管我我在贝塞尔曲线上使用了相同的简单公式.

我要做的是将两个贝塞尔曲线控制点放在正确的位置, -制作一条始终正交于两个位置之间的直线的线. -制作两个贝塞尔曲线控制点(+和-),它们位于正交线上某处的中间,并且分别位于两个位置.

但是在某些情况下(两个位置不在水平或垂直位置),该线不会像下面那样正交,因为控制点不在正交线上,我想知道latitudeDelta标度和longitudeDelta之间是否存在差异规模,这会导致问题,但不确定.

我的计算结果如下.

     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 }
 

请让我知道任何人对此问题有任何想法. 谢谢!

解决方案

经度和纬度以度为单位的千米(英里)比例不同,因此对于通常使用的投影比例因系数f=Cos(latitude)而不同,地图是各向异性的. /p>

因此您可以:

1)在屏幕坐标系中生成控制点贝塞尔曲线(像素)

2)使用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!

解决方案

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

这篇关于在地图上的正确位置制作贝塞尔曲线控制点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆