当前位置: 首页>>代码示例>>Python>>正文


Python Geometry.sqrdistance方法代码示例

本文整理汇总了Python中Geometry.sqrdistance方法的典型用法代码示例。如果您正苦于以下问题:Python Geometry.sqrdistance方法的具体用法?Python Geometry.sqrdistance怎么用?Python Geometry.sqrdistance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Geometry的用法示例。


在下文中一共展示了Geometry.sqrdistance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_Grid

# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import sqrdistance [as 别名]
    def build_Grid(self):
        
        try:

            for sph in self.dictSpheres.keys():
                
                if float(1.0 / self.Spacer) - float(int(1.0 / self.Spacer)) > 0.001:
                    xmin = float(int((self.dictSpheres[sph][1][0] - self.dictSpheres[sph][0]) / self.Spacer)) * self.Spacer;
                    ymin = float(int((self.dictSpheres[sph][1][1] - self.dictSpheres[sph][0]) / self.Spacer)) * self.Spacer;
                    zmin = float(int((self.dictSpheres[sph][1][2] - self.dictSpheres[sph][0]) / self.Spacer)) * self.Spacer;
                    xmax = float(int((self.dictSpheres[sph][1][0] + self.dictSpheres[sph][0]) / self.Spacer) + 1.0) * self.Spacer;
                    ymax = float(int((self.dictSpheres[sph][1][1] + self.dictSpheres[sph][0]) / self.Spacer) + 1.0) * self.Spacer;
                    zmax = float(int((self.dictSpheres[sph][1][2] + self.dictSpheres[sph][0]) / self.Spacer) + 1.0) * self.Spacer;

                else:
                    xmin = float(int(self.dictSpheres[sph][1][0] - self.dictSpheres[sph][0] - self.Spacer));
                    ymin = float(int(self.dictSpheres[sph][1][1] - self.dictSpheres[sph][0] - self.Spacer));   
                    zmin = float(int(self.dictSpheres[sph][1][2] - self.dictSpheres[sph][0] - self.Spacer));
                    xmax = float(int(self.dictSpheres[sph][1][0] + self.dictSpheres[sph][0] + self.Spacer + 1.0))
                    ymax = float(int(self.dictSpheres[sph][1][1] + self.dictSpheres[sph][0] + self.Spacer + 1.0))
                    zmax = float(int(self.dictSpheres[sph][1][2] + self.dictSpheres[sph][0] + self.Spacer + 1.0))


                x = xmin
                y = ymin
                z = zmin
                
                sqrrad = sph.Radius
                
                while z < zmax:
                    while y < ymax:
                        while x < xmax:

                            key  = '%8.3f' % x
                            key += '%8.3f' % y
                            key += '%8.3f' % z

                            if key not in self.dictGridPoints:

                                sqrrad = self.dictSpheres[sph][0] * self.dictSpheres[sph][0]
                                if Geometry.sqrdistance( self.dictSpheres[sph][1], [ x, y, z ] ) < sqrrad:

                                    self.dictGridPoints[key] = ''

                            x += self.Spacer

                        x = xmin
                        y += self.Spacer

                    x = xmin
                    y = ymin
                    z += self.Spacer

        except:
            return 1

        return 0
开发者ID:NRGlab,项目名称:NRGsuite,代码行数:59,代码来源:Grid.py

示例2: write_Partition

# 需要导入模块: import Geometry [as 别名]
# 或者: from Geometry import sqrdistance [as 别名]
    def write_Partition(self):
        
        listNoAtom = list()
        FromFile = self.Cleft.CleftFile

        try:
            file = open(FromFile, 'r')
            SPHLines = file.readlines()
            file.close()
        except:
            self.top.DisplayMessage("  ERROR: Could not find the parent cleft file.", 1)
            return
            
        # Write in the PDB file
        TMPFile = open(self.TempPartition, 'w')
        TMPFile.write('REMARK  PARENTFILE  ' + FromFile + '\n')            

        Vertex = 0
        for Line in SPHLines:
            if Line.startswith('ATOM  '):

                index = Line[7:11].strip()              # The atom number
                coordX = float(Line[30:38].strip())     # The atom X coordinate
                coordY = float(Line[39:46].strip())     # The atom Y coordinate
                coordZ = float(Line[47:54].strip())     # The atom Z coordinate
                radius = float(Line[61:].strip())       # The radius of the sphere                    
                    
                if listNoAtom.count(index) == 0:
                    
                    for sph in sorted(self.dictSpheres, key=str.lower):
                        
                        sqrrad  = self.dictSpheres[sph].Radius ** 2
                        sqrdist = Geometry.sqrdistance( [ coordX, coordY, coordZ ], self.dictSpheres[sph].Center )

                        #if sqrdist <= (self.dictSpheres[sph].Radius+radius)*(self.dictSpheres[sph].Radius+radius):

                        # ** NEW
                        # The center of the sphere needs to be inside the 'inserted Spheres'
                        if sqrdist <= sqrrad:

                            listNoAtom.append(index)
                            TMPFile.write(Line)
                            Vertex = Vertex + 1
                            break
                                    
        TMPFile.close()

        return Vertex
开发者ID:NRGlab,项目名称:NRGsuite,代码行数:50,代码来源:CropCleft.py


注:本文中的Geometry.sqrdistance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。