示例#1
0
    def set_size(self, axis_length, axis_radius):
        from chimerax.surface.shapes import cylinder_geometry, cone_geometry
        vaz, naz, taz = cylinder_geometry(radius=axis_radius,
                                          height=axis_length)
        vcz, ncz, tcz = cone_geometry(radius=axis_radius * 2,
                                      height=axis_length * 0.2,
                                      caps=True)
        from chimerax.geometry import Place
        vct = Place(origin=(0, 0, axis_length / 2))
        vcz = vct.transform_points(vcz)
        nv = len(vaz)
        tcz = tcz + nv
        from numpy import concatenate
        vaz = concatenate((vaz, vcz))
        naz = concatenate((naz, ncz))
        taz = concatenate((taz, tcz))
        nv = len(vaz)
        tx = Place(axes=[[0, 0, 1], [0, -1, 0], [1, 0, 0]])
        vax, nax, tax = tx.transform_points(vaz), tx.transform_vectors(
            naz), taz.copy() + nv
        ty = Place(axes=[[1, 0, 0], [0, 0, -1], [0, 1, 0]])
        vay, nay, tay = ty.transform_points(vaz), ty.transform_vectors(
            naz), taz.copy() + 2 * nv

        vc = self.vertex_colors
        self.set_geometry(concatenate((vax, vay, vaz)),
                          concatenate((nax, nay, naz)),
                          concatenate((tax, tay, taz)))
        self.vertex_colors = vc  # Setting geometry clears vertex colors
示例#2
0
def ellipsoid_geometry(center, axes, axis_lengths, num_triangles = 1000):

  from chimerax.surface import sphere_geometry
  varray, narray, tarray = sphere_geometry(num_triangles)
  narray = narray.copy()        # Is same as varray for sphere.
  from chimerax.geometry import Place, scale, normalize_vectors
  ptf = Place(axes = axes, origin = center) * scale(axis_lengths)
  ptf.transform_points(varray, in_place = True)
  ntf = Place(axes = axes) * scale([1/l for l in axis_lengths])
  ntf.transform_vectors(narray, in_place = True)
  normalize_vectors(narray)

  return varray, narray, tarray