force_measurements - list_of_force_vectors.append(fnet) j =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
from __future__ import division from visual import * f f = open('force_measurements.txt','r') list_of_force_vectors = [] j = 0 jmax = 5000 j while j<jmax: ##read the fle and store the data to variables dataline = f.readline() ##read a single line from the file forcecomponents = dataline.split() ##split the line at spaces fx = float(forcecomponents[0]) ##convert the first item to a number fy = float(forcecomponents[1]) ##convert the second item to a number fz = float(forcecomponents[2]) ##convert the third item to a number fnet = vector(fx,fy,fz) ##stores the components in a vector #add a force measurement to the list
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: list_of_force_vectors.append(fnet) j = j+1 ##increment f.close() rinitial = vector(0.132,0.018,0) ball = sphere(pos=rinitial,radius = 0.1, color = color.blue) mball = .1 vball = vector(1.93,-1.38,0) deltat = .001 pball = vball*mball balltrail = curve(color=ball.color) b for fnet in list_of_force_vectors: rate(100) pball = pball + fnet*deltat ball.pos = ball.pos + (pball/mball)*deltat balltrail.append(pos=ball.pos) vfinal = pball/mball print 'final velocity =', vfinal rdis = ball.pos-rinitial; print 'position displacement =', rdis...
View Full Document

This note was uploaded on 09/12/2011 for the course PHYISCS 2211 taught by Professor Jarrio during the Spring '10 term at Georgia Institute of Technology.

Ask a homework question - tutors are online