Help me asap!!

  • Thread starter the_proud_family
  • Start date
T

the_proud_family

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
 
N

Nick Coghlan

the_proud_family said:
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

A few comments in the code stating what each section is *meant* to be doing
might mean you actually got some useful responses (no guarantees, though).

However, the current state of the code, where the reader is left entirely to
guess as to what the overall program is for, and what each section of the
program is meant to be doing virtually guarantees that you *won't* get any help.

You could start by interpreting the cryptic comment above into something
meaningful for anyone who doesn't already know what your assignment is.

You might even find that articulating things clearly lets you identify the
problem for yourself.

Alternately, implement little pieces at a time, to make sure they work
individually, then combine them to form the complete behaviour - don't try to
write the whole thing in one hit (or you will get your current situation of "it
doesn't work" with no idea which *bit* isn't working)

Cheers,
Nick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,607
Members
45,240
Latest member
pashute

Latest Threads

Top