By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,796 Members | 1,205 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,796 IT Pros & Developers. It's quick & easy.

help asap

P: n/a

HELP ME PLEASE!! my email is th**************@yahoo.com

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=mgcos(angle)

F=mgsin(angle)

f=mu*N

lax=(-Nsin(angle)+fcos(angle))/m

lay=(-Ncos(angle)-fsin(angle)+m*g)/m

rax=(+Nsin(angle)+fcos(angle))/m

ray=(-Ncos(angle)-fsin(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(-gball.y+0.5(vx2+vy2)-fds))

ball.velocity.x=ball.velocity.x+mugdt

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-gball.y-fds))

#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


Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
the_proud_family wrote:
HELP ME PLEASE!! my email is th**************@yahoo.com

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=mgcos(angle)

F=mgsin(angle)

f=mu*N

lax=(-Nsin(angle)+fcos(angle))/m

lay=(-Ncos(angle)-fsin(angle)+m*g)/m

rax=(+Nsin(angle)+fcos(angle))/m

ray=(-Ncos(angle)-fsin(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(-gball.y+0.5(vx2+vy2)-fds))

ball.velocity.x=ball.velocity.x+mugdt

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-gball.y-fds))

#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

Let me open by saying I'm sorry of this response appears superficially
unhelpful. Please read it to the end, as it really is intended to help
despite its obstinate refusal to directly address your question.

This appears to be your third attempt to recruit help, which shows
rather poor learning behavior. You have presented what appears
(superficially, most people who contribute to this newsgroup don't have
the time to read random chunks of code and I'm usually the same) to be
the same program each time.

Might I suggest that you:

1. Explain what the program is intended to
do. If we can't know what problem you
are trying to solve we are unlikely to
be able to help.

2. Reformat your code to use leading spaces
rather than tabs (many newsreaders
handle tabs badly)

3. Add copious comments explaining what each
section of your program is supposed
to do.

With luck, those activities alone will help you to solve your own
problem. One valid debugging technique is to explain to somebody else
exactly why there can't possibly be anything wrong with your program.
Quite often you will smack your head in the middle of this activity,
having realized exactly what your mistaken assumption has been. If there
is no human available a stuffed toy can work almost as well.

Finally, please take the time to read

http://www.catb.org/~esr/faqs/smart-questions.html

as this will give you some useful clues on how to increase your chances
of getting a rely that will *actually solve your problem* rather than
just pointing out that your current behavior is unlikely to do so.

It's just occurred to me that in the time it's taken me to write this I
probably could have run your code (had it been properly formatted) and
attempted to find out what was wrong with it. So please take this advice
in the spirit of "if you give a man a fish you feed him for a day*, if
you teach him to fish you feed him for a lifetime" -- I am trying to
help you help yourself, as several others have already.

Finally, one crucial lesson for any would-be programmer is to persevere
(and you do at least score high marks there). The longer your problem
goes unsolved the better you'll feel about eventually arriving at a
solution.

regards
Steve
--
* alternative ending: if you teach him to fish, for the rest of his life
he'll bore you with stories about the one that got away.

http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.