GUI.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:CP244 作者: Unathi-Skosana 项目源码 文件源码
def plot_ellipsoid(self):
        q = 0.60
        r = ops.get_ellipse_rad(q)
        H = ops.get_hessian(self.X)
        eigv, rotation  = la.eigh(H)
        center = self.Bh

        u = np.linspace(0.0, 2.0 * np.pi, 100)
        v = np.linspace(0.0, np.pi, 100)

        x = (r/math.sqrt(eigv[0])) * np.outer(np.cos(u), np.sin(v))
        y = (r/math.sqrt(eigv[1])) * np.outer(np.sin(u), np.sin(v))
        z = (r/math.sqrt(eigv[2])) * np.outer(np.ones_like(u), np.cos(v))

        ux = (r/math.sqrt(eigv[0]))*  np.outer(np.cos(u), np.sin(v))
        uy = (r/math.sqrt(eigv[1])) * np.outer(np.sin(u), np.sin(v))
        uz = (r/math.sqrt(eigv[2])) * np.outer(np.ones_like(u), np.cos(v))

        for i in range(len(x)):
            for j in range(len(x)):
                [x[i,j],y[i,j],z[i,j]] = np.dot([x[i,j],y[i,j],z[i,j]], rotation) + center

        # plot
        fig = plt.figure()
        ax = fig.add_subplot(111, projection='3d')
        ax.plot_surface(x, y,z, rstride=2, cstride=5, color='g', alpha=0.5)
        ax.plot_surface(ux, uy, uz, rstride=2, cstride=5, color='r', alpha=0.5)
        plt.axis('equal')
        plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号