this is a german Web-Mirror of PYTHON.ORG powered by Domainunion AG

Differences between revisions 1 and 23 (spanning 22 versions)
Revision 1 as of 2005-12-15 18:02:37
Size: 485
Editor: vangw
Comment: Creating stub page for VPython
Revision 23 as of 2009-10-25 02:43:08
Size: 1227
Editor: ppp-64-109-16-57
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
VPython is an extension for Python to allow easy, "pythonic" 3D. It is used primarily for teaching physics, but can be applied to other domains readily. from visual import *
from random import uniform
Line 3: Line 4:
[https://vpython.org/ VPython Home Page] # David Scherer
Line 5: Line 6:
= Projects using VPython: scene.range = 3
Line 7: Line 8:
''This could be moved to its own page if it grows unweildy.'' a = convex(color=(0.5,0,0))
b = convex(color=(0,0.5,0))
c = convex(color=(0,0,0.5))
d = convex(color=(0.5,0,0.5))
e = convex(color=(0.5,0.5,0))
f = convex(color=(0,0.5,0.5))
Line 9: Line 15:
[https://pw1.netcom.com/~ajs/ PyGeo] # circle
t = arange(0,2*pi,0.1)
e.pos = transpose( (sin(t), cos(t)+2, 0*t) )
Line 11: Line 19:
= VPython FAQ # triangle
t = arange(0,2*pi,2*pi/3)
f.pos = transpose( (sin(t)-2, cos(t)+2, 0*t) )
Line 13: Line 23:
''This could also be moved to its own page if it grows unweildy.'' # disk
for t in arange(0,2*pi,0.1):
    a.append(pos = (cos(t),0,sin(t)))
    a.append(pos = (cos(t),0.2,sin(t)))
Line 15: Line 28:
''''How do I do X?''''
  Try using Y.
----
["CategoryPyGUI"]
# box
for i in range(8):
    p = vector((i/4)%2 - 2.5, (i/2)%2 - 0.5, (i)%2 - 0.5)
    b.append(pos=p)

# random sphere
L = []
for i in range(1000):
    L.append(vector(2,0) + norm(vector(uniform(-1,1),uniform(-1,1),uniform(-1,1))))
c.pos = L

# lat/long sphere
L = []
for t in arange(0,2*pi,0.2):
    for s in arange(0,pi,0.1):
        L.append((cos(t)*sin(s)+2, sin(t)*sin(s)+2, cos(s)))
print len(L)
d.pos = L

# modify the disk
p = a
p.color = (p.color[0]*2, p.color[1]*2, p.color[2]*2)
while 1:
    rate(10)
    if scene.mouse.clicked:
        c = scene.mouse.getclick()
        p.append(pos=c.pos)
    p.pos[-1] = scene.mouse.pos

from visual import * from random import uniform

# David Scherer

scene.range = 3

a = convex(color=(0.5,0,0)) b = convex(color=(0,0.5,0)) c = convex(color=(0,0,0.5)) d = convex(color=(0.5,0,0.5)) e = convex(color=(0.5,0.5,0)) f = convex(color=(0,0.5,0.5))

# circle t = arange(0,2*pi,0.1) e.pos = transpose( (sin(t), cos(t)+2, 0*t) )

# triangle t = arange(0,2*pi,2*pi/3) f.pos = transpose( (sin(t)-2, cos(t)+2, 0*t) )

# disk for t in arange(0,2*pi,0.1):

  • a.append(pos = (cos(t),0,sin(t))) a.append(pos = (cos(t),0.2,sin(t)))

# box for i in range(8):

  • p = vector((i/4)%2 - 2.5, (i/2)%2 - 0.5, (i)%2 - 0.5) b.append(pos=p)

# random sphere L = [] for i in range(1000):

  • L.append(vector(2,0) + norm(vector(uniform(-1,1),uniform(-1,1),uniform(-1,1))))

c.pos = L

# lat/long sphere L = [] for t in arange(0,2*pi,0.2):

  • for s in arange(0,pi,0.1):
    • L.append((cos(t)*sin(s)+2, sin(t)*sin(s)+2, cos(s)))

print len(L) d.pos = L

# modify the disk p = a p.color = (p.color[0]*2, p.color[1]*2, p.color[2]*2) while 1:

  • rate(10) if scene.mouse.clicked:
    • c = scene.mouse.getclick() p.append(pos=c.pos)
    p.pos[-1] = scene.mouse.pos

VPython (last edited 2014-03-30 00:02:54 by DaleAthanasias)

Unable to edit the page? See the FrontPage for instructions.