# shooting a basketball arc, Pixel-based

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

## Recommended Posts

Anyone know how to simulate the arc of a basketball while shooting? I'm using 16.16 fixed point. The ball when shot or moving has a vX and vY variable that is added to its x any y coordinate. The basket is at some point (b.x, b.y). Anyone know how to find the proper vX and vY amounts? This is pixel based so Moving the object by (1<<16) will move it one pixel. -Thanks for any and all help.:)

##### Share on other sites
This is where some simple physics will help.

Take the initial velocity and find the vertical and horizontal components. Then use the formula vf=vi+at where "a" is -9.8 and t is how many seconds have passed since launch/throw.

Forgot the negative.

##### Share on other sites
I already know how to create the arc. I guess my question is how do I determine the correct xVel so that the ball ALWAYS hits the rim?

##### Share on other sites
You need to tell some more about the physics you are using. The vX and vY are not constants or you would not be able to get an arc. So what do the vX and vY depend on? How are they calculated?
Then people can try to derive an equation and solve it.

##### Share on other sites
OK, but I'm using pseudo physics.

 if(ball.shot){    ball.vX = someValue;    ball.vY = anotherValue; // anotherValue is negative since the positive y-axis points down}ball.x += ball.vX;ball.vY += GRAVITY; // In this case, GRAVITY is positive to drag the ball downball.y += ball.vY;if(objCol(&ball, &rim)){    ...    //take appropriate action here    ...}

##### Share on other sites
Those are accurate enough physics, so long as you're using sufficiently small fixed-length time steps. What you need is to use the equation of a parabola to solve an arc that goes through the ball's current location, the hoop's location, and a point somewhere in the air that makes the arc drop through the hoop at the angle you want, but not so high an angle that the arc's apex is overly high.

That's why this is called a firing "solution".

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633669
• Total Posts
3013257
×