python - 如何创建椭圆形几何体

标签 python shapely drawellipse

如何根据已知的轴坐标和峰值半径创建椭圆?

来自下图:

Elips

A点和B点已知

R是fresnelZone计算的结果(以米为单位)。

点X是线串AB的质心

我还读过: thisthis 但不知道如何实现。

最佳答案

例如可以这样进行:

#!/usr/bin/env python
import math
from shapely.geometry import Point
from shapely.affinity import scale, rotate

#input parameters
A = Point(1, 1)
B = Point(4, 5)
R = 1

d = A.distance(B)

#first, rotate B to B' around A so that |AB'| = |AB| and B'.y = A.y
#and then take S as midpoint of AB'
S = Point(A.x + d/2, A.y)

#alpha represents the angle of this rotation
alpha = math.atan2(B.y - A.y, B.x - A.x)

#create a circle with center at S passing through A and B'
C = S.buffer(d/2)

#rescale this circle in y-direction so that the corresponding
#axis is R units long
C = scale(C, 1, R/(d/2))

#rotate the ellipse obtained in previous step around A into the
#original position (positive angles represent counter-clockwise rotation)
C = rotate(C, alpha, origin = A, use_radians = True)

for x,y in C.exterior.coords:
    print(x, y)

关于python - 如何创建椭圆形几何体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45158360/

相关文章:

c# - 让眼球注视/跟随光标移动 (C#)

matlab - 检测青光眼照片中的椭圆

python - 从 Python 中的命名空间获取所需选项

python - 无法在 VS 2015 中构建 Django 项目 - django\contrib\admin\widgets.py

python - 如何存储cascaded_union的坐标

python - 将 mssql 空间字段导入 geopandas/shapely 几何图形

python - 从列 python 中计算最新的相同值

python - 如何使用 django 纠正 zmq 地址使用错误

python - 溶解重叠多边形(使用 GDAL/OGR),同时保持非连接结果不同

c# - 如何在windows窗体上更快地画圆?