コード例 #1
0
    def rotate_nanoparticle(self, p1, p2, theta):

        self._p1 = p1
        self._p2 = p2
        self._theta = theta

        NUMOFP = len(self._x)

        for i in range(NUMOFP):
            p0 = point.point(self._x[i][0], self._x[i][1], self._x[i][2])
            p0 = util.point_rotate(p1, p2, p0, theta)
            self._x[i][0] = p0.get_x()
            self._x[i][1] = p0.get_y()
            self._x[i][2] = p0.get_z()

        # faccio cosi' altrimenti annullo le label
        for i in range(len(self._pinside_list)):
            p = self._pinside_list[i]
            p = util.point_rotate(p1, p2, p, theta)
            self._pinside_list[i].set_x(p.get_x())
            self._pinside_list[i].set_y(p.get_y())
            self._pinside_list[i].set_z(p.get_z())

        for i in range(len(self._psurface_list)):
            #print "Rotate: \"", self._psurface_list[i].get_label(), "\""
            p = self._psurface_list[i]
            p = util.point_rotate(p1, p2, p, theta)
            self._psurface_list[i].set_x(p.get_x())
            self._psurface_list[i].set_y(p.get_y())
            self._psurface_list[i].set_z(p.get_z())
            #print "Rotate: \"", self._psurface_list[i].get_label(), "\""

        self.__compute_triangles()
        self.__compute_plane()
コード例 #2
0
def return_rototransl_xyz(nanop, xlist, ylist, zlist):

  xlistnew = []
  ylistnew = []
  zlistnew = []

  for i in range(len(xlist)):
    xlistnew.append(xlist[i])
    ylistnew.append(ylist[i])
    zlistnew.append(zlist[i])

  xcn, ycn, zcn = nanop.get_center()

  for i in range(len(xlist)):
    xlistnew[i] = xlistnew[i] + xcn
    ylistnew[i] = ylistnew[i] + ycn
    zlistnew[i] = zlistnew[i] + zcn

  theta =nanop.get_theta()
  p2 = nanop.get_p2()
  p1 = point.point(xcn, ycn, zcn)
  
  for i in range(len(xlist)):
    p0 = point.point(xlistnew[i], ylistnew[i], zlistnew[i])
    p0 = util.point_rotate(p1, p2, p0, theta)
    xlistnew[i] = p0.get_x()
    ylistnew[i] = p0.get_y()
    zlistnew[i] = p0.get_z()

  return  xlistnew, ylistnew, zlistnew
コード例 #3
0
  def _rotate_point (self, p1, point1, angle):

    point2 = point.point(self._cx, self._cy, self._cz)

    p0 = point.point(p1[0], p1[1], p1[2])
    p0 = util.point_rotate(point2, point1, p0, angle)
    
    return [p0.get_x(), p0.get_y(), p0.get_z()]
コード例 #4
0
def rotate_as_possible(s, p0, p1, near_spheres, numbertostop):

    touching_spheres_now = []

    dtetha = common.dtetha_start
    tetha = 0.0

    c = s.get_center()
    radius = s.get_radius()

    lowest_c = c

    while tetha < (2.0 * math.pi):
        tetha += dtetha
        c_start = c

        c = util.point_rotate(p0, p1, c, tetha)
        s.set_center(c)

        #if (((c.get_z() - radius) < common.botz) or
        #    ((c.get_z() + radius) > common.topz) or \
        #    ((c.get_x() - radius) < common.botx) or
        #    ((c.get_x() + radius) > common.topx) or \
        #    ((c.get_y() - radius) < common.boty) or
        #    ((c.get_y() + radius) > common.topy)):
        #  dtetha = dtetha/10.0
        #  if dtetha <= common.min_dtetha:
        #    if (c.get_z() < lowest_c.get_z()):
        #      lowest_c = c
        #    break
        #  else:
        #    c = c_start

        touching_spheres_now = touched_other_sphere(near_spheres, s)
        if (len(touching_spheres_now) >= numbertostop):
            dtetha = dtetha / 10.0
            if dtetha <= common.min_dtetha:
                if (c.get_z() < lowest_c.get_z()):
                    lowest_c = c
                break
            else:
                c = c_start
                s.set_center(c)

        if (c.get_z() < lowest_c.get_z()):
            lowest_c = c

    if (lowest_c.get_z() < c.get_z()):
        c = lowest_c
        s.set_center(c)

    return touching_spheres_now
コード例 #5
0
ファイル: placetraps.py プロジェクト: lstorchi/Stacker
def rototranslate_traps(intraps, cx, cy, cz, p1, p2, tetha, npid):

    trap_centerx = numpy.mean([t.get_x() for t in intraps])
    trap_centery = numpy.mean([t.get_y() for t in intraps])
    trap_centerz = numpy.mean([t.get_z() for t in intraps])

    distx = trap_centerx - cx
    disty = trap_centery - cy
    distz = trap_centerz - cz

    vals = [point.point(t.get_x()-distx, t.get_y()-disty, \
        t.get_z()-distz) for t in intraps]
    rotvals = [util.point_rotate(p1, p2, p, tetha) for p in vals]
    rettraps = [traps.trap(p.get_x(), p.get_y(), p.get_z()) \
        for p in rotvals]

    # should be Vectorized
    for i in range(len(rettraps)):
        rettraps[i].set_id(intraps[i].get_id())
        rettraps[i].set_npid(npid)
        rettraps[i].set_atomid(intraps[i].get_atomid())

    return rettraps
コード例 #6
0
ファイル: xyzpacker.py プロジェクト: lstorchi/Stacker
    ylistnew = []
    zlistnew = []

    for i in range(len(xlist)):
        xlistnew.append(xlist[i])
        ylistnew.append(ylist[i])
        zlistnew.append(zlist[i])

    for i in range(len(xlist)):
        xlistnew[i] = xlistnew[i] + xcn
        ylistnew[i] = ylistnew[i] + ycn
        zlistnew[i] = zlistnew[i] + zcn

    xcn2 = float(plist[6])
    ycn2 = float(plist[7])
    zcn2 = float(plist[8])

    theta = float(plist[9])
    p2 = point.point(xcn2, ycn2, zcn2)
    p1 = point.point(xcn, ycn, zcn)

    for i in range(len(xlist)):
        p0 = point.point(xlistnew[i], ylistnew[i], zlistnew[i])
        p0 = util.point_rotate(p1, p2, p0, theta)
        xlistnew[i] = p0.get_x()
        ylistnew[i] = p0.get_y()
        zlistnew[i] = p0.get_z()

    for i in range(len(xlist)):
        print atoms[i], " ", xlistnew[i], " ", ylistnew[i], " ", zlistnew[i]