Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Determining the arc and angle of a ball

Author
Message
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 25th Jun 2009 01:36
My camera can turn on the x and y axis. Gravity is always pushing towards down. I can control how much power the ball shoots off with. If I shot a ball from my the angles my camera were looking at, how could I determine the arch, how far the ball would go, and still include gravity in the equation?

Basically, the problem is how far the camera is pointing up, increases the arch and changes the distance it will go. What math could I use to determine this?

NOTE: It's in 3D space keep that in mind, not 2D.
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Jun 2009 02:17
what i would do is take the angle of the camera and use it with circle formula:

x=cos(angle)*rad
y=sin(angle)*rad

only have the radius be the power, then save the x and y as forward and upwards variables

if the camera can turn left/right then you will also need to use the same formula to find the x change of the ball

then in flight, inc the x,y,z using the 3 variables, and dec the upwards variable to slow its upward motion, simulating gravity

if you need an example, look at the physics of my flinging challenge entry on dbchallenge.com (it might be dbchallenge, I forget)

There are only 10 kinds of people in the world, those who understand binary and those who dont
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th Jun 2009 04:37
For a more accurate description of the arc, these are the real physics formulas to use.

These are the formula's you need:

Y=.5*g*t^2+VY*t+Y0

Where:
g=Acceleration from gravity (9.8m/s^2 or 32ft/s^2)
t=The Total Time in the air
VY=The initial Velocity in the Y direction (Take the muzzle velocity and multiply it by sin(angle) that it is fired from)
Y0=The initial height of the cannon (usually 0)

The X one is similar, but if you are going to leave out air resistance (makes life SOOOO much easier) it is much simpler:
X=VX*t+X0
Where:
VX=The X component of the velocity. This can be found by multiplying the muzzle velocity*cos(angle).

The formula for X is simpler because the acceleration (which is g in the first equation) is 0 (no force slowing it down).

Velocity at a point in the arc with:
V=a*t+V0
and
V^2=V0^+2*a*(D)

Where a=acceleration, D=the displacement, and V0=the component of the muzzle velocity.

Side Note:
The X and Y components can be re-combined into its actual value using:
V=SQRT(Vx^2+Vy^2)

Hope this helps!

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Jun 2009 04:41
.......wow

There are only 10 kinds of people in the world, those who understand binary and those who dont
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th Jun 2009 04:45
3 years of physics kinda burns it into your brain. I can work out all the math to fire a cannon at a target and figure out how fast to fire it, or what angle, or pretty much anything as long as I am given the correct set of givens.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
That1Smart Guy
15
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th Jun 2009 04:50
..........wow

There are only 10 kinds of people in the world, those who understand binary and those who dont
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Jun 2009 05:27
Check out the section under "misc formulas", it describes projectile motion and how to find the maximum height and distance of the object during its arc.
http://dbchallenge.com/?page=eq

You can also determine at what time the arc of the object would hit a specific point in space by solving the equations for t (time) instead, which I did in my last DBC challenge entry.

[url="http://dbcc.zimnox.com"][/url]
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 25th Jun 2009 07:03 Edited at: 25th Jun 2009 07:09
The thing is though, I have to gradually position the object as it moves. I can't just find the end coordinates and put it from start to finish. I have to position along the way.
@Phaelax
I'll post an edit after I check up on that page.

EDIT:
@Phaelax
That's exactly what I was looking for, that helps so much.

One question though. When it says this:
x = P.x + V.x*t

Would the bolded part be a number with a decimal point or what would that be. I don't know what that means.
BN2 Productions
20
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th Jun 2009 12:09 Edited at: 25th Jun 2009 12:10
That would be the same as X0 in my formulas.

P is the starting point. P.x would be the x coordinate of the starting point.

And the equations will work. What you do is just increase T and it will track the location.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
pictionaryjr
15
Years of Service
User Offline
Joined: 12th Mar 2009
Location:
Posted: 26th Jun 2009 08:33
Thanks so much lol that makes sense now
wickedly kick it
17
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 26th Jun 2009 10:27
Eighth grade science i like to google formulas, impliment them to see if they work in dbp, usually do

Login to post a reply

Server time is: 2024-05-20 09:48:19
Your offset time is: 2024-05-20 09:48:19