示例#1
0
 def Transform(self, Center, Rotation=None, Translation=None):
     if Rotation is not None:
         if Translation is not None:
             # Fifth method
             ats = self.AllAtoms()
             for f in range(len(ats)):
                 ats[f].FCoord = geomutils.Subtract(ats[f].FCoord, Center)
                 ats[f].FCoord = geomutils.Rotate(ats[f].FCoord, Rotation)
                 ats[f].FCoord = geomutils.Add(ats[f].FCoord, Translation)
         else:
             # Fourth method
             ats = self.AllAtoms()
             for f in range(len(ats)):
                 ats[f].FCoord = geomutils.Add(ats[f].FCoord, Center)
                 ats[f].FCoord = geomutils.Rotate(ats[f].FCoord, Rotation)
     else:
         if isinstance(Center, geomutils.TRotMatrix):
             # Second method
             ats = self.AllAtoms()
             for f in range(len(ats)):
                 ats[f].FCoord = geomutils.Rotate(ats[f].FCoord, Center)
         elif isinstance(Center, geomutils.TQuaternion):
             # Third method
             ats = self.AllAtoms()
             for f in range(len(ats)):
                 ats[f].FCoord = geomutils.Rotate(ats[f].FCoord, Center)
         else:
             # First method
             ats = self.AllAtoms()
             for f in range(len(ats)):
                 ats[f].FCoord = geomutils.Add(ats[f].FCoord, Center)
示例#2
0
 def TransformedCoords(self, Coords):
     Result = []
     for f in range(len(Coords)):
         Result.append(geomutils.Subtract(Coords[f], self.FCenterVec))
         Result[f] = geomutils.RotAndPlace(self.FBaseRotation,
                                           self.FTranslation, Result[f])
     # Return TCoords
     return Result
示例#3
0
 def TranslateToTarget(self):
     c = basetypes.TCoord(
         (self.FDomainGrid.Block.XOffset +
          self.FDomainGrid.Block.ProbeEndX / 2) * self.FProbe.FResolution,
         (self.FDomainGrid.Block.YOffset +
          self.FDomainGrid.Block.ProbeEndY / 2) * self.FProbe.FResolution,
         (self.FDomainGrid.Block.ZOffset +
          self.FDomainGrid.Block.ProbeEndZ / 2) * self.FProbe.FResolution)
     return geomutils.Subtract(c, self.FTarget.TransVec)
示例#4
0
 def Center(self):
     self.FCenterVec = basetypes.TCoord()
     for f in range(len(self.FMobile)):
         self.FCenterVec = geomutils.Add(self.FCenterVec, self.FMobile[f])
     if len(self.FMobile) > 0:
         self.FCenterVec = geomutils.Multiply(self.FCenterVec,
                                              1 / len(self.FMobile))
     for f in range(len(self.FMobile)):
         self.FMobile[f] = geomutils.Subtract(self.FMobile[f],
                                              self.FCenterVec)
示例#5
0
 def Torsion(self, Pivot, Axis):
     Result = 0
     for f in range(len(self.FDerivs)):
         AtDeriv = self.FDerivs[f]
         if (AtDeriv[0] is not 0) or (AtDeriv[1] is not 0) or (AtDeriv[2]
                                                               is not 0):
             v1 = geomutils.Subtract(self.FPositions[f], Pivot)
             v1 = geomutils.CrossProduct(Axis, v1)
             Result = Result + geomutils.DotProduct(v1, AtDeriv)
     # Return TFloat
     return Result
示例#6
0
def SubtractTest():
    c = basetypes.TCoord(0, 1, 2)
    c = geomutils.Subtract(c, 1)
    print(str(c[0]) + ' ' + str(c[1]) + ' ' + str(c[2]))

    c = basetypes.TCoord(6, 3, 9)
    c2 = basetypes.TCoord(3, 5, 1)
    c = geomutils.Subtract(c, c2)
    print(str(c[0]) + ' ' + str(c[1]) + ' ' + str(c[2]))

    print('')
    ca = []
    c = basetypes.TCoord(3, 8, 1)
    ca.append(c)
    c = basetypes.TCoord(6, 4, 6)
    ca.append(c)
    c = basetypes.TCoord(0, 2, 5)
    ca.append(c)
    c = basetypes.TCoord(5, 1, 3)
    ca = geomutils.Subtract(ca, c)
    for f in range(len(ca)):
        print(str(ca[f][0]) + ' ' + str(ca[f][1]) + ' ' + str(ca[f][2]))
示例#7
0
def CalcCenterHull(Atoms, Dist):
    if Atoms is None:
        # Return TCuboid
        return basetypes.TCuboid()
    else:
        c1 = Atoms[0].Coords
        c2 = c1
        for f in range(1, len(Atoms)):
            c1 = basetypes.Min(c1, Atoms[f].Coords)
            c2 = basetypes.Max(c2, Atoms[f].Coords)
        c1 = geomutils.Subtract(c1, Dist)
        c2 = geomutils.Add(c2, Dist)
        # Return TCuboid
        return basetypes.TCuboid(c1, c2)
示例#8
0
 def PlaneConstraint(self, Point, Normal, Margin):
     # Scaling factors for the shapes
     tres = 1 / self.FTargetResolution
     pres = 1 / self.FProbeResolution
     # Plane and line variables
     planepoint = geomutils.Subtract(
         geomutils.Add(Point, geomutils.Multiply(self.FTargetTransVec,
                                                 tres)),
         geomutils.Multiply(self.FProbeTransVec, pres))
     planepoint = geomutils.Subtract(
         planepoint,
         basetypes.TCoord(self.FDomainBlock.XOffset,
                          self.FDomainBlock.YOffset,
                          self.FDomainBlock.ZOffset))
     xflags = basetypes.FilledInts(self.FDomainBlock.DomainEndX + 1, -1)
     yflags = basetypes.FilledInts(self.FDomainBlock.DomainEndY + 1, -1)
     zflags = basetypes.FilledInts(self.FDomainBlock.DomainEndZ + 1, -1)
     for x in range(len(self.FXDomain)):
         for xx in range(self.FXDomain[x][0], self.FXDomain[x][1] + 1):
             self.SetYDomain(xx, yflags, zflags, planepoint, Normal, Margin)
             if self.FYDomainAtX[xx] is not None and (len(
                     self.FYDomainAtX[xx]) != 0):
                 xflags[xx] = 1
     self.FXDomain = linegrids.IntegersToLine(xflags)
示例#9
0
 def EvaluateAndDerive(self, Point, Deriv):
     Result = 0
     for f in range(3):
         self.FRotation[f] = Point[f]
         Point[f] = 0
         self.FTranslation[f] = Point[f + 3]
     RotMatrix = self.CurrentRotation()
     for f in range(len(self.FMobile)):
         Coords = geomutils.RotAndPlace(RotMatrix, self.FTranslation,
                                        self.FMobile[f])
         Dist = (Coords[0] - self.FFixed[f][0]) ** 2 + (Coords[1] - self.FFixed[f][1]) ** 2 + \
                (Coords[2] - self.FFixed[f][2]) ** 2
         Result = Result + Dist
         self.FDerivs[f] = geomutils.Subtract(self.FFixed[f], Coords)
         self.FPositions[f] = Coords
     self.GetDerivatives(Deriv)
     # Return TFloat
     return Result
示例#10
0
 def Dock(self, NumSteps=1, CalcStats=False):
     while (self.FCurrentRotation < len(self.FRotations) - 1) and (NumSteps
                                                                   > 0):
         self.FCurrentRotation = self.FCurrentRotation + 1
         NumSteps = NumSteps - 1
         ticktime = 0
         if CalcStats:
             ticktime = basetypes.GetTickCount()
         self.BuildProbeGrid(self.FRotations[self.FCurrentRotation])
         if CalcStats:
             self.DigitizationTicks = basetypes.GetTimeInterval(ticktime)
             self.ConstraintTicks = 0
             self.DomainTicks = 0
             self.ScoringTicks = 0
         for f in range(len(self.FConstraintSets)):
             self.FModelManagers[f].FCurrentRotation = self.FRotations[
                 self.FCurrentRotation]
             dockdomain = dockdomains.TDockDomain(self.FTargetGrid,
                                                  self.FProbeGrid)
             dockdomain.FConstraintManager.ImportConstraints(
                 self.FConstraintSets[f].Constraints,
                 self.FRotations[self.FCurrentRotation],
                 self.FAxes[self.FCurrentRotation])
             if CalcStats:
                 self.ConstraintTicks = self.ConstraintTicks + basetypes.GetTimeInterval(
                     ticktime)
             dockdomain.AssignModelManager(self.FModelManagers[f].FAddModel)
             dockdomain.MinimumOverlap = self.FModelManagers[
                 f].MinimumOverlap
             dockdomain.RemoveCores = True
             dockdomain.BuildInitialModel()
             if CalcStats:
                 self.DomainTicks = self.DomainTicks + basetypes.GetTimeInterval(
                     ticktime)
             self.FModelManagers[f].ProbeGridTransVec = geomutils.Subtract(
                 self.FProbeGrid.FTransVec, self.FTargetGrid.FTransVec)
             dockdomain.Score()
             if CalcStats:
                 self.ScoringTicks = self.ScoringTicks + basetypes.GetTimeInterval(
                     ticktime)
     # Return Boolean
     return self.FCurrentRotation == len(self.FRotations) - 1