Archived

This topic is now archived and is closed to further replies.

Calculating the arc of a ball between two points

This topic is 5119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

This is probably a dumb question, but my math skills are a bit weak. What I''m trying to do is calculate the arc of a ball (basketball in this case) as it moves from the release point to the end point, which are both known. So I want to calculate the x and y axis of the ball as it arcs between the two points. This is done in a 2d environment. Any help is greatly appreciated, Mike

Share on other sites
why not start with a half-circle? u can allways scale it down to form more "flat" arc...

Share on other sites
The beginning point and end point are not enough information. There are many physically correct quadratic arcs which pass through any two given points. You''ll also need something to specify how high the arc goes (such as initial velocity). As a start-off point, you''re going to need an equation of the form y=ax*x+b*x+c which fulfils the system of equations represented by the initial and final points. I''m sure you can find somewhere the method of doing that given 3 points (as I said, the initial and final points aren''t enough by themselves).

The official zorx website

Share on other sites
there are an infinite number of solutions to that question. it could be thrown very fast and straight or it could be thrown in a high arc. try this out with a real life ball.

you also need to know the angle at which it is released and then you can solve for how fast it needs to be going. essentially the angle of release is entirely arbirtary. then you can use simple physics kinematics to solve for the high point and whatnot.

d = 1/2 a * t^2 for a falling object

d = height
a = gravity (9.8 meters/s/s)
t = time

i'll have to dredge up more physics memories or spend more time on this if you want the full solution. for now, work out the angle of release and speed of the ball.

-me

[edited by - Palidine on February 19, 2004 8:20:28 PM]

Share on other sites
Ok,

Currently I do have a 3rd point which is supposed to be the height of the arc. I calculate the X coordinate by dividing the distance between the two points in half. The Y coordinate is static.

Also of note the y coordinate of the end point may be above or below the release point since it is moveable while the end point is fixed.

Thanks again,

Mike

Share on other sites
There are some pat "formulae" i can give you...

If everything starts off and ends at the same height:

Range=(initial velocity)2*sin(2*angle)/g

Height=Range*tan(angle)- g/(2*v2*cos(angle))Range2

... If these are wrong, they''re from my physics notes. :-/ I didn''t bother to re-derive them for accuracy.

Scout

All polynomials are funny - some to a higher degree.
Furthermore, polynomials of degree zero are constantly funny.

Share on other sites
I''d say the first thing that you will want to know is how far apart the start and end points are from each other. The next step is to get the amount of time that the ball will take to fall and make it''s full parabola. To do this, you will need the vertical velocity of the basketball. When you have this, you can find out how many seconds the ball will take to fall. And finally, when you have how many seconds it will take the ball to fall, you can divide the total horizontal distance by the number of seconds it will take, giving you the amount the ball will travel horizontally every second.
Good luck, dude. Hope this helps you.

Share on other sites
I''ve done some more work on this and am as confused as ever.

I''m still not clear on how to get the high point of the arc.

Say the end coords are (30,90) and the beginning coords are (100,120).

Now the current way I get the middle point for the x coord is (100-30)/2 which is 35. However I hardcode say 20 for the Y coord.

The current code moves the ball to the midpoint''s x,y coords simply by subtracting/adding 6 from the x and y coords until the point is reached, then it does a similar thing for getting to the end point.

This of course results in an ugly animation that is not realistic.

I''ve also tried timing this and it varies depending on the starting point.

Thanks,

Mike

Share on other sites
the thing is, you have too little information.

try getting some other infomation that makes sense.
for example, we want the angle where the ball goes into the basket to be quite steep, so there is lesschance of it bouncing back, yet not too steep for it would mean throwing the bal too high. say a 45 degree angle is optimal, then you have all the equations you need to construct the parabole. (you can also come up with other extra information, which might make more sense)

for x=pos1: ax^2+bx+c=height1
for x=pos2: ax^2+bx+c=height2
for x=pos2: 2ax + b = 1 (the derivative of the quadratic formula has a slope of 1, ie 45 degrees)

this is solvable with just a little bit of mathematical knowledge.

Share on other sites
I've gotten some work done on this problem, and I think it works pretty good. I have a net(red circle) and a shooter.(green circle) You can move the shooter back and forth, causing the xshooter variable to change. Heres my source code:
(It's in QB 4.5, but eh, it works

SCREEN 12
CLS
verticalv = 50
start:
CLS
verticallist = verticalv
gravity = 10
xend = 600
xstart = 10
ballx = xstart
bally = 440
DO
press$= INKEY$
lastx = ballx
lasty = bally
IF press$= "d" THEN xstart = xstart + 1 PSET (xstart - 1, 440), 0 ballx = ballx + 1 END IF IF press$ = "a" THEN
xstart = xstart - 1
PSET (xstart + 1, 440), 0
ballx = ballx - 1
END IF
LINE (ballx - 4, bally - 4)-(ballx + 4, bally + 4), 0, BF
CIRCLE (ballx, bally), 3
CIRCLE (xstart, 440), 2, 2
CIRCLE (xend, 440), 2, 4
WAIT &H3DA, 8
time = (verticalv / 10) + ((verticalv / 10) + 1)
ballhorizontal = (xend - xstart) / time
LOCATE 1, 1
PRINT "Horizontal Velocity:"; (xend - xstart) / time
LOCATE 2, 1
PRINT "Pixels to go:"; ballhorizontal * time
LOCATE 3, 1
IF press$= " " THEN ballx = ballx + ballhorizontal bally = bally - verticallist verticallist = verticallist - gravity LINE (lastx, lasty)-(ballx, bally), 2 LOCATE 4, 1 PRINT "Total time it will take: "; time; " seconds" END IF IF press$ = "c" THEN
INPUT "What is your new velocity"; verticalv
GOTO start
END IF
LOOP UNTIL press$= CHR$(27)

Spacebar plays the "animation" a and d move the shooter to the left and to the right.
The number of frames in the animation is determined by the vertical velocity. The equation I have to calculate time is (verticalv / 10) + ((verticalv / 10) + 1)
I'm not sure if this is the real one or not, but it works int the program, so I left it there.

The only part that I'm having some trouble on is the time. As you can see above, I've hardcoded the time into the equation, making you have to go into QB and re-compile if you want to change anything.
I know that there is a time formula that you can get from the vertical velocity, but I forget what it is. I'll look through my physics stuff and try to find it.
Good luck. Hope this stuff helps

[edited by - jedis1000 on February 20, 2004 11:14:08 AM]