示例#1
0
 def _N2oneH(self, atom, known, unknown):
     r = atom.position()
     r1 = known[0].position()
     others = filter(lambda a: a.symbol != 'H', known[0].bondedTo())
     r2 = others[0].position()
     try:
         plane = Objects3D.Plane(r, r1, r2)
     except ZeroDivisionError:
         # We get here when all three points are colinear.
         # Add a small random displacement as a fix.
         from MMTK.Random import randomPointInSphere
         plane = Objects3D.Plane(r, r1, r2 + randomPointInSphere(0.001))
     axis = (r - r1).normal()
     cone = Objects3D.Cone(r, axis, 0.5 * self._hch_angle)
     sphere = Objects3D.Sphere(r, self._nh_bond)
     circle = sphere.intersectWith(cone)
     points = circle.intersectWith(plane)
     unknown[0].setPosition(points[0])
示例#2
0
 def _findPosition(self, unknown, a1, a2, a3, bond, angle, dihedral):
     sphere = Objects3D.Sphere(a1, bond)
     cone = Objects3D.Cone(a1, a2 - a1, angle)
     plane = Objects3D.Plane(a3, a2, a1)
     plane = plane.rotate(Objects3D.Line(a1, a2 - a1), dihedral)
     points = sphere.intersectWith(cone).intersectWith(plane)
     for p in points:
         if (a1 - a2).cross(p - a1) * (plane.normal) > 0:
             unknown.setPosition(p)
             break
示例#3
0
 def _N4twoH(self, atom, known, unknown):
     r = atom.position()
     r1 = known[0].position()
     r2 = known[1].position()
     plane = Objects3D.Plane(r, r1, r2)
     axis = -((r1 - r) + (r2 - r)).normal()
     plane = plane.rotate(Objects3D.Line(r, axis), 90. * Units.deg)
     cone = Objects3D.Cone(r, axis, 0.5 * self._hnh_angle)
     sphere = Objects3D.Sphere(r, self._nh_bond)
     circle = sphere.intersectWith(cone)
     points = circle.intersectWith(plane)
     unknown[0].setPosition(points[0])
     unknown[1].setPosition(points[1])
示例#4
0
 def _N3twoH(self, atom, known, unknown):
     r = atom.position()
     r1 = known[0].position()
     others = filter(lambda a: a.symbol != 'H', known[0].bondedTo())
     r2 = others[0].position()
     plane = Objects3D.Plane(r, r1, r2)
     axis = (r - r1).normal()
     cone = Objects3D.Cone(r, axis, 0.5 * self._hnh_angle)
     sphere = Objects3D.Sphere(r, self._nh_bond)
     circle = sphere.intersectWith(cone)
     points = circle.intersectWith(plane)
     unknown[0].setPosition(points[0])
     unknown[1].setPosition(points[1])
示例#5
0
 def _tetrahedralH(self, atom, known, unknown, bond):
     r = atom.position()
     n = (known[0].position() - r).normal()
     cone = Objects3D.Cone(r, n, Numeric.arccos(-1. / 3.))
     sphere = Objects3D.Sphere(r, bond)
     circle = sphere.intersectWith(cone)
     others = filter(lambda a: a.symbol != 'H', known[0].bondedTo())
     others.remove(atom)
     other = others[0]
     ref = (Objects3D.Plane(circle.center, circle.normal) \
            .projectionOf(other.position())-circle.center).normal()
     p0 = circle.center + ref * circle.radius
     p0 = Objects3D.rotatePoint(
         p0, Objects3D.Line(circle.center, circle.normal), 60. * Units.deg)
     p1 = Objects3D.rotatePoint(
         p0, Objects3D.Line(circle.center, circle.normal), 120. * Units.deg)
     p2 = Objects3D.rotatePoint(
         p1, Objects3D.Line(circle.center, circle.normal), 120. * Units.deg)
     unknown[0].setPosition(p0)
     unknown[1].setPosition(p1)
     unknown[2].setPosition(p2)