Example #1
0
def test_3d_rot():
    import geometry
    p = [10,1,1]
    t = geometry.create_transformation_to_coincide_point_with_z_axis( [-9,1,4], p)
    print t.transform_xyz( *p)
    print t.transform_xyz( -9,1,4)
    inv = t.get_inverse()
    print inv.transform_xyz( *t.transform_xyz( *p))
Example #2
0
def test_3d_rot():
    import geometry
    p = [10, 1, 1]
    t = geometry.create_transformation_to_coincide_point_with_z_axis(
        [-9, 1, 4], p)
    print t.transform_xyz(*p)
    print t.transform_xyz(-9, 1, 4)
    inv = t.get_inverse()
    print inv.transform_xyz(*t.transform_xyz(*p))
Example #3
0
 def _get_3dtransform_for_drawing( self, b):
   """this is a helper method that returns a transform3d which rotates
   a bond and its neighbors to coincide with the x-axis and rotates neighbors to be in (x,y)
   plane."""
   atom1, atom2 = b.vertices
   x1,y1,z1 = atom1.coords
   x2,y2,z2 = atom2.coords
   t = geometry.create_transformation_to_coincide_point_with_z_axis( [x1,y1,z1],[x2,y2,z2])
   x,y,z = t.transform_xyz( x2,y2,z2)
   # now rotate to make the plane of neighbor atoms coincide with x,y plane
   angs = []
   for n in atom1.neighbors + atom2.neighbors:
     if n is not atom1 and n is not atom2:
       nx,ny,nz = t.transform_xyz( *n.coords)
       ang = math.atan2( ny, nx)
       if ang < -0.00001:
         ang += math.pi
       angs.append( ang)
   ang = sum( angs) / len( angs)
   t.set_rotation_z( ang + math.pi/2.0)
   t.set_rotation_y( math.pi/2.0)
   return t
Example #4
0
 def _get_3dtransform_for_drawing(self, b):
     """this is a helper method that returns a transform3d which rotates
 a bond and its neighbors to coincide with the x-axis and rotates neighbors to be in (x,y)
 plane."""
     atom1, atom2 = b.vertices
     x1, y1, z1 = atom1.coords
     x2, y2, z2 = atom2.coords
     t = geometry.create_transformation_to_coincide_point_with_z_axis(
         [x1, y1, z1], [x2, y2, z2])
     x, y, z = t.transform_xyz(x2, y2, z2)
     # now rotate to make the plane of neighbor atoms coincide with x,y plane
     angs = []
     for n in atom1.neighbors + atom2.neighbors:
         if n is not atom1 and n is not atom2:
             nx, ny, nz = t.transform_xyz(*n.coords)
             ang = math.atan2(ny, nx)
             if ang < -0.00001:
                 ang += math.pi
             angs.append(ang)
     ang = sum(angs) / len(angs)
     t.set_rotation_z(ang + math.pi / 2.0)
     t.set_rotation_y(math.pi / 2.0)
     return t