【发布时间】:2021-05-05 15:39:22
【问题描述】:
我已经检查了以下问题:
Plot Ellipse with matplotlib.pyplot (Python)
How to find the point on ellipse given the angle
我正在尝试在旋转的椭圆上找到一个点坐标,实际上我需要可以在图像上显示的点坐标。
这是代码,其中大部分来自第一个 SO 问题。
u=1. #x-position of the center
v=0.5 #y-position of the center
a=2. #radius on the x-axis
b=1.5 #radius on the y-axis
t_rot=pi/4 #rotation angle
angle = 15 # always on blue circle
t = np.linspace(0, 2*pi, 100)
Ell = np.array([a*np.cos(t) , b*np.sin(t)])
#u,v removed to keep the same center location
R_rot = np.array([[cos(t_rot) , -sin(t_rot)],[sin(t_rot) , cos(t_rot)]])
#2-D rotation matrix
Ell_rot = np.zeros((2,Ell.shape[1]))
for i in range(Ell.shape[1]):
Ell_rot[:,i] = np.dot(R_rot,Ell[:,i])
#ellipses
plt.plot( u+Ell[0,:] , v+Ell[1,:] ) #initial ellipse
plt.plot( u+Ell_rot[0,:] , v+Ell_rot[1,:],'magenta' ) #rotated ellipse
#points
plt.scatter(u,v,s=10,color='black') # center
plt.scatter(u + a*cos(angle),v + b*sin(angle),s=50,color='black') #point on blue ellipse
plt.grid(color='lightgray',linestyle='--')
plt.show()
如果我改变角度,我会在未旋转的椭圆(黑点)上得到一个点。
我想要做的是找到我用红色人工标记的旋转椭圆上的点。基本上这些是椭圆上具有最小和最大 x-y 值的点。
有什么建议吗?
非常感谢!
【问题讨论】:
-
一般来说,您要查找的内容称为边界框;对该词的网络搜索可能会找到一些资源。顺便说一句,您是否试图在不实际计算所有点的情况下找到边界框?
-
@Robert Dodier,感谢“边界框”概念,我一定会调查的。
-
@Pranav Hosangadi,我不知道如何回复您的评论。我没明白你的意思。先生,您能分享您的专业知识并解释一下吗?
标签: python math linear-algebra ellipse