GaussClasses.py 文件源码

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

项目:livespin 作者: biocompibens 项目源码 文件源码
def draw2D_new(self):
        for i in xrange(self.nComponents):
            k1 = np.array([[self.params[6 * i + 3] ** 2, self.params[6 * i + 3] * self.params[6 * i + 4] * self.params[6 * i + 5]],
                           [self.params[6 * i + 3] * self.params[6 * i + 4] * self.params[6 * i + 5], self.params[6 * i + 4] ** 2]])
            w1, v1 = np.linalg.eig(k1)
            idx = w1.argsort()
            w1 = w1[idx]
            v1 = v1[:, idx]
            angle=-(np.arctan(v1[1][1]/v1[0][1]))+np.pi#x+2*(pi/4-x)+pi/2#since in the image X and Y are inverted, so need to minus 90 degree and flip around pi/4

            w2 = np.zeros((1 , 2))
            w2[0,1] = np.sqrt(2)*np.max([self.params[6 * i + 3], self.params[6 * i + 4]])
            w2[0,0] = w2[0,1]*w1[0]/w1[1]

            xeq = lambda t: w2[0,1] * np.cos(t) * np.cos(angle) + w2[0,0] * np.sin(
                t) * np.sin(angle) + self.params[6 * i + 1]
            yeq = lambda t: - w2[0,1] * np.cos(t) * np.sin(angle) + w2[0,0] * np.sin(
                t) * np.cos(angle) + self.params[6 * i + 2]
            t = np.linspace(0, 2 * np.pi, 100)
            x = xeq(t)
            y = yeq(t)
            pylab.scatter(self.params[6 * i + 2], self.params[6 * i +1], color='k')
            pylab.plot(y.astype(int), x.astype(int), self.colors[i] + '-')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号