コード例 #1
0
    def __init__(self, object):

        if object.__class__.__name__ == 'atom_builder':
            self.atom_object = object

            self.visual = vis.sphere(
                pos=self.atom_object.pos,
                radius=visual.atom_radii[self.atom_object.element],
                color=visual.atom_colors[self.atom_object.element])
            visual.all_visual_atoms.append(self)

        if object.__class__.__name__ == 'bond_builder':
            self.bond_object = object

            if self.bond_object.number_of_bonds == 1:
                self.bond_object.bonds = 'single'
            if self.bond_object.number_of_bonds == 2:
                self.bond_object.bonds = 'double'

            self.visual = vis.cylinder(
                radius=self.bond_object.number_of_bonds * 0.05,
                pos=self.bond_object.atom1.pos,
                axis=self.bond_object.atom2.pos - self.bond_object.atom1.pos,
                color=visual.bond_color[self.bond_object.bonds])

            visual.all_visual_bonds.append(self)
コード例 #2
0
ファイル: toomanyspheres.py プロジェクト: rknop/physvis
def main():
    spheres = []
    for i in range(2000):
        spheres.append(
            physvis.sphere(pos=(random.random() * 5 - 2.5,
                                random.random() * 5 - 2.5,
                                random.random() * 5 - 2.5),
                           radius=0.05,
                           color=(random.random(), random.random(),
                                  random.random())))

    while True:
        physvis.rate(30)
コード例 #3
0
    def __init__(self, object):

        if object.__class__.__name__ == 'atom':
            self.atom_object = object
            self.visual = vis.sphere(pos=object.pos,
                                     radius=visual.atom_radii[object.element],
                                     color=visual.atom_colors[object.element])
            visual.all_visual_atoms.append(self)

        if object.__class__.__name__ == 'bond':
            self.bond_object = object
            self.visual = vis.cylinder(radius=0.05,
                                       pos=object.atom1.pos,
                                       axis=object.atom2.pos -
                                       object.atom1.pos,
                                       color=(0.4, 0.7, 0.9))

            visual.all_visual_bonds.append(self)