def _neighborSegment_ok_for_crossover_search(
        self,
        neighborSegment,
        reference_segment_end1,
        reference_segment_axisVector):

        ok_for_search = False
        orthogonal_vector = None

        neighbor_end1 , neighbor_end2 = neighborSegment.getAxisEndPoints()
        #Use end1 of neighbor segment and find out the perpendicular
        #distance (and the vector) between this atom and the
        #axis vector of dnaSegment (whose neighbors are being
        #searched). If this distance is less than a specified amount
        #then 'neighbor' is an approved neighbor of 'dnaSegment'
        if neighbor_end1 is not None:
            p1 = reference_segment_end1
            v1 = reference_segment_axisVector
            p2 = neighbor_end1
            dist, orthogonal_dist = orthodist(p1, v1, p2)

            #Check if the orthogonal distance is withing the
            #specified limit.
            if orthogonal_dist <= MAX_PERPENDICULAR_DISTANCE_BET_SEGMENT_AXES:
                ok_for_search = True
                vec = p1 + dist*v1 - p2
                orthogonal_vector = orthogonal_dist*norm(vec)

                if self.graphicsMode.DEBUG_DRAW_PLANE_NORMALS:
                        self._DEBUG_plane_normals_ends_for_drawing.append(
                            (p2, (p2 + orthogonal_vector)) )

        return ok_for_search, orthogonal_vector
Esempio n. 2
0
    def _mirrorChunk(self, chunkToMirror):
        """
        Converts the given chunk into its own mirror.

        @param chunkToMirror: The chunk that needs to be converted into its own
               mirror chunk.
        @type  chunkToMirror: instance of class Chunk
        @see:  self.Mirror
        """
        m = chunkToMirror
        # ninad060813 Following gives an orthogonal distance between the
        #chunk center and mirror plane.
        self.mirrorDistance, self.wid = orthodist(m.center,
                                                  self.mirrorAxis,
                                                  self.mirrorJigs[0].center)
        # @@@@ ninad060813 This moves the mirror chunk on the other side of
        # the mirror plane. It surely moves the chunk along the axis of the
        # mirror plane but I am still unsure if this *always* moves the
        # chunk on the other side of the mirror.
        #Probably the 'orthodist' function has helped me here??
        m.move(2*(self.mirrorDistance)*self.mirrorAxis)

        m.stretch(-1.0)
        m.rot(Q(self.mirrorAxis, pi))
        return
Esempio n. 3
0
    def _mirrorJig(self, jigToMirror):
        """
        Converts the given jig into its own mirror. If the jig is a motor,
        it also reverses its direction.
        @param jigToMirror: The jig that needs to be converted into its own
               mirror jig.
        @type  jigToMirror: instance of class Jig
        @see:  self.Mirror
        """
        j = jigToMirror
        # ninad060813 This gives an orthogonal distance between the chunk
        # center and mirror plane.

        #Fixed bug 2503.
        if not (isinstance(j, Motor) or isinstance(j, ESPImage)):
            return

        self.mirrorDistance, self.wid = orthodist(j.center, self.mirrorAxis,
                                                  self.mirrorJigs[0].center)
        j.move(2*(self.mirrorDistance)*self.mirrorAxis)

        j.rot(Q(self.mirrorAxis, pi))

        #Reverse the direction of Linear and Rotary motor for correct
        #mirror operation
        if isinstance(j, Motor):
            j.reverse_direction()
        return
Esempio n. 4
0
 def findHandles_exact(self, p1, p2, cutoff = 0.0, backs_ok = 1, offset = V(0,0,0)):
     """
     return a list of (dist, handle) pairs, in arbitrary order,
     which includes, for each handle (spherical surface) hit by the ray from p1 thru p2,
     its front-surface intersection with the ray,
     unless that has dist < cutoff and backs_ok,
     in which case include its back-surface intersection
     (unless *that* has dist < cutoff).
     """
     #e For now, just be simple, don't worry about speed.
     # Someday we can preprocess self.handlpos using Numeric functions,
     # like in nearSinglets and/or findSinglets
     # (I have untested prototype code for this in extrude-outs.py).
     hh = self.handles
     res = []
     v = norm(p2-p1)
     ## is this modifying the vector in-place, causing a bug?? offset += self.origin # treat our handles' pos as relative to this
     ## I don't know, but one of the three instances of += was doing this!!! probably i was resetting the atom or mol pos....
     offset = offset + self.origin # treat our handles' pos as relative to this
     radius_multiplier = self.radius_multiplier
     for (pos,radius,info) in hh:
         ## bug in this? pos += offset
         pos = pos + offset
         radius *= radius_multiplier
         dist, wid = orthodist(p1, v, pos)
         if radius >= wid: # the ray hits the sphere
             delta = sqrt(radius*radius - wid*wid)
             front = dist - delta # depth from p1 of front surface of sphere, where it's hit
             if front >= cutoff:
                 res.append((front,(pos,radius,info)))
             elif backs_ok:
                 back = dist + delta
                 if back >= cutoff:
                     res.append((back,(pos,radius,info)))
     return res
Esempio n. 5
0
 def _mirrorJig(self, jigToMirror):
     """
     Converts the given jig into its own mirror. If the jig is a motor, 
     it also reverses its direction.
     @param jigToMirror: The jig that needs to be converted into its own
            mirror jig. 
     @type  jigToMirror: instance of class Jig
     @see:  self.Mirror
     """
     j = jigToMirror
     # ninad060813 This gives an orthogonal distance between the chunk 
     # center and mirror plane.
     
     #Fixed bug 2503. 
     if not (isinstance(j, Motor) or isinstance(j, ESPImage)):
         return
     
     self.mirrorDistance, self.wid = orthodist(j.center, self.mirrorAxis, 
                                               self.mirrorJigs[0].center)         
     j.move(2*(self.mirrorDistance)*self.mirrorAxis)
     
     j.rot(Q(self.mirrorAxis, pi))
     
     #Reverse the direction of Linear and Rotary motor for correct 
     #mirror operation
     if isinstance(j, Motor):
         j.reverse_direction()
     return
Esempio n. 6
0
 def _mirrorChunk(self, chunkToMirror):
     """
     Converts the given chunk into its own mirror. 
     
     @param chunkToMirror: The chunk that needs to be converted into its own
            mirror chunk. 
     @type  chunkToMirror: instance of class Chunk
     @see:  self.Mirror
     """
     m = chunkToMirror
     # ninad060813 Following gives an orthogonal distance between the 
     #chunk center and mirror plane.
     self.mirrorDistance, self.wid = orthodist(m.center, 
                                               self.mirrorAxis, 
                                               self.mirrorJigs[0].center) 
     # @@@@ ninad060813 This moves the mirror chunk on the other side of 
     # the mirror plane. It surely moves the chunk along the axis of the 
     # mirror plane but I am still unsure if this *always* moves the 
     # chunk on the other side of the mirror. 
     #Probably the 'orthodist' function has helped me here?? 
     m.move(2*(self.mirrorDistance)*self.mirrorAxis)
     
     m.stretch(-1.0)
     m.rot(Q(self.mirrorAxis, pi))
     return
Esempio n. 7
0
    def _neighborSegment_ok_for_crossover_search(self, neighborSegment,
                                                 reference_segment_end1,
                                                 reference_segment_axisVector):

        ok_for_search = False
        orthogonal_vector = None

        neighbor_end1, neighbor_end2 = neighborSegment.getAxisEndPoints()
        #Use end1 of neighbor segment and find out the perpendicular
        #distance (and the vector) between this atom and the
        #axis vector of dnaSegment (whose neighbors are being
        #searched). If this distance is less than a specified amount
        #then 'neighbor' is an approved neighbor of 'dnaSegment'
        if neighbor_end1 is not None:
            p1 = reference_segment_end1
            v1 = reference_segment_axisVector
            p2 = neighbor_end1
            dist, orthogonal_dist = orthodist(p1, v1, p2)

            #Check if the orthogonal distance is withing the
            #specified limit.
            if orthogonal_dist <= MAX_PERPENDICULAR_DISTANCE_BET_SEGMENT_AXES:
                ok_for_search = True
                vec = p1 + dist * v1 - p2
                orthogonal_vector = orthogonal_dist * norm(vec)

                if self.graphicsMode.DEBUG_DRAW_PLANE_NORMALS:
                    self._DEBUG_plane_normals_ends_for_drawing.append(
                        (p2, (p2 + orthogonal_vector)))

        return ok_for_search, orthogonal_vector
Esempio n. 8
0
 def findHandles_exact(self,
                       p1,
                       p2,
                       cutoff=0.0,
                       backs_ok=1,
                       offset=V(0, 0, 0)):
     """
     @return: a list of (dist, handle) pairs, in arbitrary order, which
     includes, for each handle (spherical surface) hit by the ray from p1
     thru p2, its front-surface intersection with the ray, unless that has
     dist < cutoff and backs_ok, in which case include its back-surface
     intersection (unless *that* has dist < cutoff).
     """
     #e For now, just be simple, don't worry about speed.
     # Someday we can preprocess self.handlpos using Numeric functions,
     # like in nearSinglets and/or findSinglets
     # (I have untested prototype code for this in extrude-outs.py).
     hh = self.handles
     res = []
     v = norm(p2 - p1)
     # is this modifying the vector in-place, causing a bug??
     ## offset += self.origin # treat our handles' pos as relative to this
     # I don't know, but one of the three instances of += was doing this!!!
     # probably i was resetting the atom or mol pos....
     offset = offset + self.origin  # treat our handles' pos as relative to this
     radius_multiplier = self.radius_multiplier
     for (pos, radius, info) in hh:
         ## bug in this? pos += offset
         pos = pos + offset
         radius *= radius_multiplier
         dist, wid = orthodist(p1, v, pos)
         if radius >= wid:  # the ray hits the sphere
             delta = sqrt(radius * radius - wid * wid)
             front = dist - delta  # depth from p1 of front surface of sphere, where it's hit
             if front >= cutoff:
                 res.append((front, (pos, radius, info)))
             elif backs_ok:
                 back = dist + delta
                 if back >= cutoff:
                     res.append((back, (pos, radius, info)))
     return res