Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.mso.anu.edu.au/pfrancis/simulations/pulsar.py
Дата изменения: Sat Apr 12 09:43:37 2014
Дата индексирования: Sun Apr 10 03:51:14 2016
Кодировка:
from __future__ import division
from visual import *
import random
import math

scene = display(range=(1.0,1.0,1.0),width=1400,height=800,forward=(0.2,0.6,-1.0))

scene.lights=[]
scene.ambient = color.gray(0.2)

theta = 0.0

# Set up neutron star
nspos = vector(0.0,0.0,0.0)
nsrad = 0.1
nscol = (0.4,0.4,0.4)
ns = sphere(pos = nspos, radius = nsrad, color=nscol)


beamlen = 20.0
beamoffset = 1.5*beamlen
lightfrac = 0.005
beampos = vector(beamlen*math.cos(theta),beamlen*math.sin(theta),beamoffset)
beam1 = cone(pos = beampos, axis = -1.0*beampos, color=(0.5,0.4,1.0),
opacity = 0.3, width = 1.0,
material=materials.emissive)
beam1light = local_light(pos=lightfrac*beampos,
color=(1.0,0.2,1.0))

beam2 = cone(pos = -1.0*beampos, axis = beampos, color=(0.5,0.4,1.0),
opacity = 0.1, width = 1.0,
material=materials.emissive)
beam2light = local_light(pos=-1.0*lightfrac*beampos,
color=(1.0,0.2,1.0))

flare = box(pos = -1.0*scene.forward,
axis = -1.0*scene.forward, width = 10, height = 10,
color=(1.0,0.2,1.0),visible=False)

dtheta = 0.03
while 1:
rate(100)
theta += dtheta
beampos = vector(beamlen*math.cos(theta),beamlen*math.sin(theta),beamoffset)
beam1.pos = beampos
beam1.axis = -1.0*beampos
beam1light.pos = lightfrac*beampos
angle = diff_angle(beam1.axis,scene.forward)
beam1.opacity = 0.8*math.cos(angle)
if angle < 0.05:
flare.visible=True
scene.ambient = color.gray(1.0)
else:
flare.visible=False
scene.ambient = color.gray(0.2)
beam2.pos = -1.0*beampos
beam2.axis = beampos
beam2light.pos = -1.0*lightfrac*beampos