- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用了以下代码,仅输入start_point
和end_point
:
import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches
start_point = (25, 50)
end_point = (50, 25)
center = (25, 25)
radius = (25
# We need to some how automatically calculate this midpoint
mid_point = (45, 45)
verts = [start_point, mid_point, end_point]
codes = [Path.MOVETO, Path.CURVE3, Path.CURVE3]#, Path.CLOSEPOLY]
path = Path(verts, codes)
shape = patches.PathPatch(path, facecolor='none', lw=0.75)
plt.gca().add_patch(shape)
plt.axis('scaled')
我得到以下输出
我需要以下输出(我使用 MS Paint
创建了以下输出)
[说明:将圆弧转换为以直线连接的点集。我需要这些点集作为列表]
最佳答案
要获取沿通过曲线(CURVE3
或 CURVE4
)定义的路径的坐标,您可以使用 Path
的 .to_polygons()
方法。这将给出一个 N x 2 形状的坐标数组。
poly, = path.to_polygons()
plt.plot(*zip(*poly), marker="o", ls="None")
<小时/>
无法操纵 .to_polygon
创建的点数。如果这是一个要求,您可以创建您的 own Bezier curve从给定的点开始,如下所示。这里我们选择路径上的 32 个点。
import matplotlib.pyplot as plt
import numpy as np
from scipy.special import binom
bernstein = lambda n, k, t: binom(n,k)* t**k * (1.-t)**(n-k)
def bezier(points, num=200):
N = len(points)
t = np.linspace(0, 1, num=num)
curve = np.zeros((num, 2))
for i in range(N):
curve += np.outer(bernstein(N - 1, i, t), points[i])
return curve
start_point = (25, 50)
end_point = (50, 25)
mid_point = (45, 45)
nodes1 = np.array([start_point, mid_point, end_point])
curve1 = bezier(nodes1, num=32)
plt.plot(curve1[:,0], curve1[:,1], color="red", ls="", marker="o", ms=3)
plt.axis('scaled')
plt.show()
关于python - 使用 Python Matplotlib 使用起点、终点、中心和半径将圆弧绘制为多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50346166/
我需要用一些数据计算弧长: 起始点坐标(Xs、Ys、Zs) 结束点及坐标(Xe、Ye、Ze) 中心点及坐标(Xc、Yc、Zc) Axis 向量,包含分量(Xa、Ya、Za) Arc 从 Start 点
通常 UICollectionView 在滚动超过它的 contentSize 时开始反弹,即当 contentOffset contentSize.width用于水平方向。 是否可以更改此行为,以
我的要求是,当表格宽度大于当前视口(viewport)时,必须添加左右两个按钮。当用户单击左侧按钮时,表格必须向左移动,同样向右移动。 所以我决定使用 jQuery 动画方法来完成要求。我的挑战是,我
我有一堆坡道,我想知道它们的起点和终点(如果有多个起点/终点,我想知道它们是如何连接的)。我目前将这些作为 List ret = new List(); FilteredElementCollecto
我使用了以下代码,仅输入start_point和end_point: import matplotlib.pyplot as plt from matplotlib.path import Path
我正在尝试从 mapr fs origin 进行简单的数据移动到 mapr fs destination (这不是我的用例,只是为了测试目的做这个简单的 Action )。尝试 validate 时这
我是一名优秀的程序员,十分优秀!