Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python计算基于原点、端点、中心、距离和方向的圆弧坐标_Python_Geometry_Coordinates_Point_Curve - Fatal编程技术网

使用python计算基于原点、端点、中心、距离和方向的圆弧坐标

使用python计算基于原点、端点、中心、距离和方向的圆弧坐标,python,geometry,coordinates,point,curve,Python,Geometry,Coordinates,Point,Curve,具有下列信息: 原点:点(横向原点、纵向原点) 终点:点(横向、纵向) 中心点:点(横向中心、纵向中心) 距离:100 轴承:90º 我希望能够以尽可能少的点生成尽可能接近的圆弧,从而获得近似值的坐标 一个好的功能是能够控制误差容限,并能够动态调整点数以近似圆弧 我们必须记住,我们使用的是坐标,不能忽略曲面曲率 预期输出将是一个函数,该函数获取原点、端点、中心点、距离、方位和可选的误差公差作为输入,并作为输出返回一系列从原点到端点的点坐标,这些坐标大致形成所需的圆弧 相关链接: 任何帮助都

具有下列信息:

  • 原点:点(横向原点、纵向原点)
  • 终点:点(横向、纵向)
  • 中心点:点(横向中心、纵向中心)
  • 距离:100
  • 轴承:90º
我希望能够以尽可能少的点生成尽可能接近的圆弧,从而获得近似值的坐标

一个好的功能是能够控制误差容限,并能够动态调整点数以近似圆弧

我们必须记住,我们使用的是坐标,不能忽略曲面曲率

预期输出将是一个函数,该函数获取原点、端点、中心点、距离、方位和可选的误差公差作为输入,并作为输出返回一系列从原点到端点的点坐标,这些坐标大致形成所需的圆弧

相关链接:

任何帮助都将不胜感激。

from shapely.geometry import Point
origin_point = Point(...,...)
end_point = Point(...,...)
center_point = Point(...,...)
distance = 100
bearing = 90
import math
import numpy as np
from shapely.geometry import Point, LineString

def get_bearing(center_point, end_point):
    
    lat3 = math.radians(end_point[0])
    long3 = math.radians(end_point[1])
    lat1 = math.radians(center_point[0])
    long1 = math.radians(center_point[1])
    
    dLon = long3 - long1
    
    X = math.cos(lat3) * math.sin(dLon)
    Y = math.cos(lat1) * math.sin(lat3) - math.sin(lat1) * math.cos(lat3) * math.cos(dLon)
    
    end_brng = math.atan2(X, Y)
    
    return end_brng

def get_arc_coordinates(center_point, origin_point, end_point, brng_init, distance):
    '''
    center_point: (center_latitude, center_long) 
    origin_point: (origin_latitude, origin_long) 
    end_point: (end_latitude, end_long)
    brng_init: degrees
    distance: aeronautical miles
    '''
    
    brng_init = math.radians(brng_init) #Bearing in degrees converted to radians.
    d = distance * 1.852 #Distance in km
    
    R = 6378.1 #Radius of the Earth
    brng = get_bearing(center_point,end_point) #1.57 #Bearing is 90 degrees converted to radians.
    
    list_bearings = np.arange(brng, brng_init, 0.1) # 0.1 value to be modify with tolerance
    
    coordinates = []
    
    for i in list_bearings:
        lat1 = math.radians(center_point[0]) #Center lat point converted to radians
        lon1 = math.radians(center_point[1]) #Center long point converted to radians
        brng = i
        lat2 = math.asin( math.sin(lat1)*math.cos(d/R) +
             math.cos(lat1)*math.sin(d/R)*math.cos(brng))
        
        lon2 = lon1 + math.atan2(math.sin(brng)*math.sin(d/R)*math.cos(lat1),
                     math.cos(d/R)-math.sin(lat1)*math.sin(lat2))
        
        lat2 = math.degrees(lat2)
        lon2 = math.degrees(lon2)
        
        coordinates.append(Point(lat2, lon2))

    return LineString(coordinates)