You Are Here:

Community: Developer Discussion Boards

#1 Old Parabolic effect - 2004-03-02, 05:04

Join Date: Mar 2004
Posts: 1
Location: Bangalore,India
sssmails
Offline
Registered User
How can i get a parabolic path when two end coordinates given along with the maximum height. To draw on a canvas.
Reply With Quote

#2 Old 2004-03-03, 01:35

Join Date: Apr 2003
Posts: 61
aspaans
Offline
Regular Contributor
Do you want the curve that you get when throwing a ball into the air?:

OK... let's dreg up some math-stuff from highschool :-)


Then, the equation for that could be written as:

Code:
   
  x = Vx*t
  y = (.5A)*t^2 + Vy*t

  t  = time in secones.
  Vx = initial horizontal speed (m/s)
  Vy = initial vertical speed (upwards in m/s)
  A  = Gravity (A < 0, works against Vy) (m/s^2)
normalize it where Vx = 1, so divide all by Vx
Code:
   
  x = t
  y = (A/2Vx)*t^2 + (Vy/Vx)*t    
  
This (y) is the graph you want to draw. 
Read the rest of the post to figure out the values 
for A, Vx, Vy and the maximum value for t.
First, see where the ball touches the ground:
I remember this problem ...
Code:
   
  P*t^2 + Q*t + R = 0,
  where P=A/2Vx, Q = Vy/Vx, R = 0
has the solution..
Code:
   
  y = 0 when t = (-Q/2P) +/- square_root(Q^2 - 4PR) / (2P)
  y = 0 when t = (-Q/2P) +/- square_root(Q^2) / (2P)
  y = 0 when t = (-Q/2P) +/- Q/(2P)
  y = 0 when t = 0 or t = -Q/P = -(Vy/Vx)/(A/2Vx)

Min Distance time:
   t = 0
Max Distance time:
   t = 2Vy/(-A)

The highest point is reached when the vertical speed reaches zero:
Code:
   
  0 = A*t + Vy ==> t = -Vy/A
Fill this into the original equation to get the highest/max height:
Code:
   
  t = -Vy/A
  y = (.5A)*t^2 + Vy*t
  y = (.5A)*(-Vy^2/A^2) - Vy*Vy/A = -(Vy^2/2A)

Max Height:
  y = Vy^2/(-2A)
So here are the max height and the distance you throw:
Code:
   
  MAX_HEIGHT = (Vy^2)/(-2A)
  MAX_DIST   = Vx*t = (Vx * 2Vy)/(-A)
Now, any combination of Vy and A (as long as Vy>0 and A<0) that give the given MAX_HEIGHT is valid.
Use this combination in MAX_DIST and find a suitable value for Vx to get the given MAX_DIST.

I hope i have this right... highschool has been while.. :-)

(See also http://mathworld.wolfram.com/Parabola.html (but reverse the X and Y axis))
Last edited by aspaans : 2004-03-03 at 17:48.
Reply With Quote

#3 Old Re: Parabolic effect - 2008-09-05, 09:39

Join Date: Jun 2008
Posts: 3
Location: Bangalore
binukjames's Avatar
binukjames
Offline
Registered User
how to impliment it in game canvas ?
can u give one sample code .

because i also got stuck with this issue.....
i m trying to throw a ball based on force & direction (user have the option to select force and direction)
Reply With Quote

#4 Old Re: Parabolic effect - 2008-09-05, 10:30

Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
bogdan.galiceanu's Avatar
bogdan.galiceanu
Offline
Forum Nokia Champion
See if this thread helps.
Reply With Quote

#5 Old Re: Parabolic effect - 2008-09-05, 10:31

Join Date: Apr 2007
Posts: 1,757
Tiger79's Avatar
Tiger79
Offline
Forum Nokia Champion
hehe,
why dont u make the game for us also ? ;)

seriuosly :
i m trying to throw a ball based on force & direction (user have the option to select force and direction)


Well the force u could set up a formula which is relational to the supplied formula for the distance :

MAX_DIST = Vx*t = (Vx * 2Vy)/(-A)

u might want to say that twice the used force twice the distance or make up an own proportion between the two variables...

And about the direction, which obviously translates to an angle.. U can use this angle to deifine the height reached by the ball. Unfortunately u cant use the supplied formulae because (if im not mistaken!) it is for throwing a ball in the air without defining an angle...

and how to design it on the canvas : well u got documentation for that, I guess u'd like to draw an arc so give al ook at the graphics.drawarc method...

anyways google is ur best friend :
look for parabolic trajectory ;)

http://www.opencollege.com/simsim/ph...c%20trajectory

http://en.wikipedia.org/wiki/Trajectory

http://hyperphysics.phy-astr.gsu.edu...raj.html#tra12

hundreds more after 10 secs of searching...

off-topic : didnt u have a B.Sc Mathematics ? this all should be common knowledge then ?
Last edited by Tiger79 : 2008-09-05 at 10:51.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia