Help me asap!!

the_proud_family the_proud_family at yahoo.com
Sat Dec 4 05:55:58 CET 2004


HELP ME PLEASE!!
I can't get the ball to go up right side and then I need it to turn 
around and keep turning until velocity=0 I have been at it for the 
past 2 weeks now i give up and call for help. Please if anyone can 
gide me through i will be so grateful!! I have pasted my code below








from cmath import *
from visual import *

floor1 = box(length=10, height=0.5, width=4, color=color.blue)
floor1.pos = (-6,4,0)
floor1.axis= (5,-5,0)

floor2 = box(length=10, height=0.5, width=4, color=color.blue)
floor2.pos = (6,4,0)
floor2.axis= (-5,-5,0)

floor3 = box(length=7, height=0.5, width=4, color=color.blue)
floor3.pos = (0,1.25,0)

ball= sphere(radius=0.5, color=color.red)
ball.pos=(-8.6,7.5,0)
m=3. #kg
angle=asin(3.6/5.)#radians
g=-9.8
mu=.2
N=m*g*cos(angle)
F=m*g*sin(angle)
f=mu*N
lax=(-N*sin(angle)+f*cos(angle))/m
lay=(-N*cos(angle)-f*sin(angle)+m*g)/m
rax=(+N*sin(angle)+f*cos(angle))/m
ray=(-N*cos(angle)-f*sin(angle)+m*g)/m
ds=0.01
dt=0.01
vx=lax*dt
vy=lay*dt
ball.velocity=vector(vx,vy,0)

#print a

while 1:
    rate(100)
    ball.velocity.x=ball.velocity.x+lax*dt
    ball.velocity.y=ball.velocity.y+lay*dt
    ball.pos=ball.pos+ball.velocity*dt
    if ball.x>-3.5 and ball.x<=3.5:
        vx=sqrt(2*(-g*ball.y+0.5*(vx**2+vy**2)-f*ds))
        ball.velocity.x=ball.velocity.x+mu*g*dt
        ball.velocity.y=0
        ball.pos=ball.pos+ball.velocity*dt
    if ball.x>3.5 and ball.x<8.6:
        vx=vx*cos(angle)
        vy=sqrt(2/m*(m*-g*ball.y-f*ds))
        #print vy
        vy=vy*sin(angle)
        #print vy
        ball.velocity.x=ball.velocity.x+rax*dt
        ball.velocity.y=ball.velocity.y+ray*dt
        ball.pos=ball.pos+ball.velocity*dt
        #print ball.pos









More information about the Python-list mailing list