查找 2 条折线之间的角度
Posted
技术标签:
【中文标题】查找 2 条折线之间的角度【英文标题】:Find Angle between 2 polylines 【发布时间】:2013-09-04 06:23:09 【问题描述】:我在 MkMapView 中的 MKPolyLineView 上的 2 组坐标之间绘制 MKPolyLines。一条线是从一个点到另一点的实际路线,而另一条线是两点之间的最短距离。我已经成功绘制了 2 组线。现在我需要找到两条线之间的方向角度。尽管我付出了很多努力,但我还是没有找到任何有用的东西。需要帮助。
这就是我绘制折线的方式。
self.routeLine = [MKPolyline polylineWithCoordinates:pointsToUse count:[array count]];
self.straightLine = [MKPolyline polylineWithCoordinates:straightLinePoints count:2];
[self.map addOverlay:self.routeLine];
[self.map addOverlay:self.straightLine];
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay
if(overlay == self.routeLine)
// ylineView *polyLineView = [[MKPolylineView alloc] initWithPolyline:self.polyLine];
polyLineView = [[MKPolylineView alloc] initWithPolyline:self.routeLine];
polyLineView.lineWidth = 2;
polyLineView.strokeColor = [UIColor lightGrayColor];
polyLineView.backgroundColor = [UIColor grayColor];
return polyLineView;
else
polyLineView = [[MKPolylineView alloc] initWithPolyline:self.straightRouteLine];
polyLineView.lineWidth = 2;
polyLineView.strokeColor = [UIColor redColor];
polyLineView.backgroundColor = [UIColor redColor];
return polyLineView;
【问题讨论】:
如果两条线不是两条直线,则它们之间没有单一的角度。既然你的两条线都在同一个点上,你在说什么角度?也许提供一张图片。 【参考方案1】:我在 Python 中编写了一些代码来实现这一点。我可以稍后回家后发布代码,但它看起来像这样:
angle = atan2(y2 - y1, x2 - x1) * 180 / PI;
【讨论】:
以上是关于查找 2 条折线之间的角度的主要内容,如果未能解决你的问题,请参考以下文章
echarts 折线图 第二条折线的值总是第一条折线加第二条折线的和,怎么设置为不是这样