From: Steve S. <st...@sp...> - 2009-09-12 12:04:00
|
Hi Lenore, It's about python assignments. You are assigning the *same* acceleration vector to both objects, then changing the y component of the same vector. Instead of assigning both accelerations to the same vector (gravity) try initializing them with different vectors: pixie.acceleration = vector(0,-9.8,0) air.acceleration = vector(0,-9.8,0) then when you fiddle with the y components, it will be the y components of different vector objects. That should work! -steve On Sep 12, 2009, at 7:26 AM, Lenore Horner wrote: > Sorry. I was in too big a hurry and forgot to paste the code. Here > it is. I've put arrows off to the right indicating the lines where > both air.acceleration and pixie.acceleration are being changed despite > the fact that only air.acceleration appears in the code. I've > included all of the while loop. I don't see anywhere that I'm > reassigning pixie.acceleration from its original value of gravity but > it changes as soon as it hits those to statements (and not before). > > Thanks, > Lenore > > > angle = math.pi/4 > speed = 13.0 > > power = 2 > constant = 1 > > gravity = vector(0,-9.8,0) > > launch_velocity = vector(speed*math.cos(angle),speed*math.sin > (angle),0) > > pixie = sphere(pos=vector(-9,-3.55,0), radius=0.2, color=color.red) > pixie.velocity = launch_velocity > pixie.acceleration = gravity > > air = sphere(pos=vector(-9,-3.55,0.3), radius=0.15, color=color.blue) > air.velocity = launch_velocity > air.acceleration = gravity > > scene.mouse.getclick() # Don't launch until we're watching > > dt = 0.01 > while 1: > rate(100) > air.pos = air.pos + air.velocity*dt > if air.y < -3.55: > air.velocity = vector(0,0,0) > else: > air.velocity = air.velocity + air.acceleration*dt > air.acceleration.y = gravity.y - sign(air.velocity.y) * > constant * air.radius * air.velocity.y**power <----- > print "5", air.acceleration, pixie.acceleration > air.acceleration.x = -sign(air.velocity.x) * constant * > air.radius * air.velocity.x**power <------- > print "6", air.acceleration, pixie.acceleration > > pixie.pos = pixie.pos + pixie.velocity*dt > if pixie.y < -3.55: > pixie.velocity = vector(0,0,0) > else: > pixie.velocity = pixie.velocity + pixie.acceleration*dt > > > On Sep 11, 2009, at 18:20 , Bruce Sherwood wrote: > >> Can you explain the context of your question? I have no idea what >> program or >> documentation you're referring to. >> >> Bruce Sherwood >> >> Lenore Horner wrote: >>> Perhaps I'm just blind, but I can't figure out why the assignment >>> statements above print "5" and print "6" affect both acceleration >>> vectors, but they do. How do I change the acceleration vector of >>> one >>> object without touching the vector of other objects? >>> >>> Thanks, >>> Lenore >> >> --------------------------------------------------------------------- >> --------- >> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 >> 30-Day >> trial. Simplify your report design, integration and deployment - and >> focus on >> what you do best, core application coding. Discover what's new with >> Crystal Reports now. http://p.sf.net/sfu/bobj-july >> _______________________________________________ >> Visualpython-users mailing list >> Vis...@li... >> https://lists.sourceforge.net/lists/listinfo/visualpython-users > > > ---------------------------------------------------------------------- > -------- > Let Crystal Reports handle the reporting - Free Crystal Reports > 2008 30-Day > trial. Simplify your report design, integration and deployment - > and focus on > what you do best, core application coding. Discover what's new with > Crystal Reports now. http://p.sf.net/sfu/bobj-july > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users |