Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.mso.anu.edu.au/pfrancis/simulations/barges_light.py
Дата изменения: Tue Apr 15 06:09:36 2014
Дата индексирования: Sun Apr 10 04:47:38 2016
Кодировка:

Поисковые слова: п п п п п п п п
from __future__ import division
from visual import *

scene = display(range=(3.0,3.0,3.0),width=1300,height=800,forward=(0.2,-0.3,-1.0))

water = box(pos=(0,-0.1,0.0), length=10, width=3, height=0.1, color=(0.1,0.2,1.0))

alength = 2.0

theta = 0.1
pos1 = vector(0,0,0.6)
barge1 = box(pos = pos1, length = 2, width = 0.5,
height = 0.1, color=(0.6,0.4,0.2))
x1 = arrow(pos = pos1+vector(0,0.1,0), axis=(1,0,0), color=color.white,
shaftwidth=0.03)
tex1 = text(text = "x", pos = x1.pos+x1.axis, height=0.1, depth=0.02)
y1 = arrow(pos = pos1+vector(0,0.1,0), axis=(0,0,1), color=color.white,
shaftwidth=0.03)
tey1 = text(text = "y", pos = y1.pos+y1.axis, height=0.1, depth=0.02)
z1 = arrow(pos = pos1+vector(0,0.1,0), axis=(0,1,0), color=color.white,
shaftwidth=0.03)
tez1 = text(text = "z", pos = z1.pos+z1.axis, height=0.1, depth=0.02)
clock1 = cylinder(pos = pos1+vector(-0.2,0.2,0.0),axis=(0,0,0.02),
radius = 0.1, color=(0.8,0.8,0.2))
hand1a = cylinder(pos = clock1.pos+vector(0,0,0.01),
axis = 0.1*vector(math.cos(theta),math.sin(theta),0.0),
color=(0.2,0.3,0.1),radius = 0.015)
hand1b = cylinder(pos = clock1.pos+vector(0,0,0.005),
axis = 0.06*vector(math.cos(theta/60.0),math.sin(theta/60.0),0.0),
color=(0.2,0.3,0.1),radius = 0.02)
head1 = sphere(pos = pos1+vector(-0.1,0.5,0.0), radius = 0.07, color=color.green)
body1 = cylinder(pos = head1.pos, axis=vector(0,-0.3,0), radius = 0.03,
color=color.green)
arm1a = cylinder(pos = head1.pos+vector(0,-0.1,0), axis=vector(-0.15,-0.15,0),
radius = 0.02, color=color.green)
arm1b = cylinder(pos = head1.pos+vector(0,-0.1,0), axis=vector(0.15,-0.15,0),
radius = 0.02, color=color.green)
leg1a = cylinder(pos = head1.pos+body1.axis, axis=vector(0.1,-0.15,0),
radius = 0.02, color=color.green)
leg1b = cylinder(pos = head1.pos+body1.axis, axis=vector(-0.1,-0.15,0),
radius = 0.02, color=color.green)
light = sphere(pos = arm1b.pos+arm1b.axis, radius = 0.03, color=(0.2,0.2,0.2),
material=materials.emissive)
lightlight = local_light(pos = light.pos, color=color.yellow, visible=False)
detector = cylinder(pos = light.pos+vector(0.9,0.0,0.0), axis=(-0.1,0.0,0.0),
radius = 0.03, color = color.red)
support = cylinder(pos = detector.pos, axis=(0.0,-0.3,0.0),
radius = 0.01, color = (0.3,0.3,0.3))

pos2 = vector(0,0,-0.6)
barge2 = box(pos = pos2, length = 2, width = 0.5,
height = 0.1, color=(0.6,0.4,0.2))
x2 = arrow(pos = pos2+vector(0,0.1,0), axis=(1,0,0), color=color.white,
shaftwidth=0.03)
tex2 = text(text = "x'", pos = x2.pos+x2.axis, height=0.1, depth=0.02)
y2 = arrow(pos = pos2+vector(0,0.1,0), axis=(0,0,1), color=color.white,
shaftwidth=0.03)
tey2 = text(text = "y'", pos = y2.pos+y2.axis, height=0.1, depth=0.02)
z2 = arrow(pos = pos2+vector(0,0.1,0), axis=(0,1,0), color=color.white,
shaftwidth=0.03)
tez2 = text(text = "z'", pos = z2.pos+z2.axis, height=0.1, depth=0.02)
clock2 = cylinder(pos = pos2+vector(-0.2,0.2,0.0),axis=(0,0,0.02),
radius = 0.1, color=(0.8,0.8,0.2))
hand2a = cylinder(pos = clock2.pos+vector(0,0,0.01),
axis = 0.1*vector(math.sin(theta),math.cos(theta),0.0),
color=(0.4,0.3,0.1),radius = 0.015)
hand2b = cylinder(pos = clock2.pos+vector(0,0,0.005),
axis = 0.06*vector(math.sin(theta/60.0),math.cos(theta/60.0),0.0),
color=(0.4,0.3,0.1),radius = 0.02)



v1 = vector(0.001,0.0,0.0)
v2 = vector(-0.001,0.0,0.0)
dt1 = 0.01
dt2 = 0.01
theta1 = 0.0
theta2 = 0.0
t = 0
while 1:
t += 1
rate(100)
theta1 += dt1
barge1.pos += v1
x1.pos += v1
tex1.pos += v1
y1.pos += v1
tey1.pos += v1
z1.pos += v1
tez1.pos += v1
clock1.pos += v1
hand1a.pos += v1
hand1a.axis = 0.1*vector(math.sin(theta1),math.cos(theta1),0.0)
hand1b.pos += v1
hand1b.axis = 0.06*vector(math.sin(theta1/60.0),math.cos(theta1/60.0),0.0)
head1.pos += v1
body1.pos += v1
arm1a.pos += v1
arm1b.pos += v1
leg1a.pos += v1
leg1b.pos += v1
light.pos += v1
lightlight.pos += v1
support.pos += v1
detector.pos += v1
if t == 400:
light.color=color.white
lightlight.visible=True



theta2 += dt2
barge2.pos += v2
x2.pos += v2
tex2.pos += v2
y2.pos += v2
tey2.pos += v2
z2.pos += v2
tez2.pos += v2
clock2.pos += v2
hand2a.pos += v2
hand2a.axis = 0.1*vector(math.sin(theta2),math.cos(theta2),0.0)
hand2b.pos += v2
hand2b.axis = 0.06*vector(math.sin(theta2/60.0),math.cos(theta2/60.0),0.0)