Fysik 1/Logbog uge 39
Fra Meinertz Wiki
< Fysik 1
Version fra 30. sep 2009, 19:40 af Meinertz (diskussion | bidrag)
# -*- coding: utf-8 -*-
from visual import *
from random import gauss
ball=sphere(pos=(0,0,0),radius=0.05,color=color.blue)
arrowtails="atorigin"
#avec=arrow(color=color.green,shaftwidth=0.1)
#vvec=arrow(color=color.yellow,shaftwidth=0.3)
ball.mass=5
ball.acceleration=vector(0,-9.82,0)
path=curve(radius=0.01,color=color.red)
autoscale=1 #this off auto scaling!
scene.range=(2,1,2) #gives the property range to the scene object
scene.center=(1.5,0,0)
dt=0.0002 #dt is delta t and is 0.1 second if we are using MKS
#loop for 5 seconds:
throws = 25 #hvor mange gange der skal kastes
thrown = 0 # hvor mange gange der er kastet
# til statistik
gennemsnit = 2.768
intervaller =
while thrown < throws:
ball.pos = (0,0,0)
ball.velocity=vector(gauss(3.71,0.134),gauss(3.71,0.134),0)
thrown += 1
t=0 #start at time 0
while ball.pos.y >= 0:
#rate(1000) #slows animation by 1/arg seconds
ball.velocity = ball.velocity+ball.acceleration*dt
ball.pos=ball.pos+ball.velocity*dt
t=t+dt
path.append(pos=ball.pos)
#avec.axis=ball.acceleration
#vvec.axis=ball.velocity
#if arrowtails=="onball":
# avec.pos=ball.acceleration
# vvec.pos=ball.vel
#if arrowtails=="atorigin":
# avec.pos=ball.pos
# vvec.pos=ball.pos
print "----"
print thrown
print t
print ball.pos.x
totlen += ball.pos.x