示例#1
0
    def __init__(self, parent=None):

        Qt.QMainWindow.__init__(self, parent)
        self.frame = Qt.QFrame()
        self.vl = Qt.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        vp = Plotter(qtWidget=self.vtkWidget, axes=2, N=2)

        cn = Cone()
        cc = Cube().pos(1, 1, 1).color("pink")
        ss = Torus()
        vp.show(cn, cc, at=0)
        vp.show(ss, at=1, viewup="z")

        self.start(vp)
示例#2
0
    def __init__(self, parent=None):

        Qt.QMainWindow.__init__(self, parent)
        self.frame = Qt.QFrame()
        self.vl = Qt.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        vp = Plotter(offscreen=1, interactive=0, axes=2, N=2)

        cn = Cone()
        cc = Cube().pos(1, 1, 1).color('pink')
        ss = Torus()
        vp.show([cn, cc], at=0)
        vp.show(ss, at=1, viewup='z')

        self.start(vp)
示例#3
0
"""
Use a scalar to paint colored bands on a mesh,
this can be combined with opacities values for each vertex of the mesh.
Keyword depthpeeling improves the rendering of translucent objects.
"""
from vtkplotter import show, Hyperboloid, Torus, Text
from numpy import linspace

doc = Text(__doc__, c="k", bg="lg")

hyp = Hyperboloid()
scalars = hyp.coordinates()[:, 2]  # let z-coord be the scalar
hyp.pointColors(scalars, bands=5, cmap="rainbow")  # make color bands

tor = Torus(thickness=0.3)
scalars = tor.coordinates()[:, 2]  # let z-coord be the scalar
transp = linspace(1, 0.5, len(scalars))  # set transparencies from 1 -> .5
tor.pointColors(scalars, alpha=transp, bands=3, cmap="winter")

show(hyp, tor, doc, viewup="z", depthpeeling=1, axes=2)
示例#4
0
k = 1.4E-23  # Boltzmann constant
T = 300  # room temperature
dt = 1.5E-5
#############################################################


def reflection(p, pos):
    n = norm(pos)
    return np.dot(np.identity(3) - 2 * n * n[:, np.newaxis], p)


vp = Plotter(title='gas in toroid', interactive=0, axes=0, bg='w')

vp.add(Text(__doc__))

vp.add(Torus(c='g', r=RingRadius, thickness=RingThickness,
             alpha=.1).wire(1))  ### <--

Atoms = []
poslist = []
plist, mlist, rlist = [], [], []
mass = Matom * Ratom**3 / Ratom**3
pavg = np.sqrt(2. * mass * 1.5 * k *
               T)  # average kinetic energy p**2/(2mass) = (3/2)kT

for i in range(Natoms):
    alpha = 2 * np.pi * random()
    x = RingRadius * np.cos(alpha) * .9
    y = RingRadius * np.sin(alpha) * .9
    z = 0
    Atoms = Atoms + [vp.add(Sphere(pos=(x, y, z), r=Ratom, c=i))]  ### <--
    theta = np.pi * random()
示例#5
0
文件: gas.py 项目: neoglez/vtkplotter
RingRadius = 1
k = 1.4e-23  # Boltzmann constant
T = 300  # room temperature
dt = 1.5e-5
#############################################################


def reflection(p, pos):
    n = versor(pos)
    return np.dot(np.identity(3) - 2 * n * n[:, np.newaxis], p)


vp = Plotter(title="gas in toroid", interactive=0, axes=0)

vp += Text2D(__doc__)
vp += Torus(c="g", r=RingRadius, thickness=RingThickness,
            alpha=0.1).wireframe(1)  ### <--

Atoms = []
poslist = []
plist, mlist, rlist = [], [], []
mass = Matom * Ratom**3 / Ratom**3
pavg = np.sqrt(2.0 * mass * 1.5 * k *
               T)  # average kinetic energy p**2/(2mass) = (3/2)kT

for i in range(Natoms):
    alpha = 2 * np.pi * random()
    x = RingRadius * np.cos(alpha) * 0.9
    y = RingRadius * np.sin(alpha) * 0.9
    z = 0
    atm = Sphere(pos=(x, y, z), r=Ratom, c=i)
    vp += atm