Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Mar 2004

    Parabolic effect

    How can i get a parabolic path when two end coordinates given along with the maximum height. To draw on a canvas.

  2. #2
    Regular Contributor
    Join Date
    Apr 2003
    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:

      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
      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 ...
      P*t^2 + Q*t + R = 0,
      where P=A/2Vx, Q = Vy/Vx, R = 0
    has the solution..
      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:
      0 = A*t + Vy ==> t = -Vy/A
    Fill this into the original equation to get the highest/max height:
      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:
      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 16:48.

  3. #3
    Registered User
    Join Date
    Jun 2008

    Re: Parabolic effect

    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)

  4. #4
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Deva, Romania

    Re: Parabolic effect

    See if this thread helps.

  5. #5
    Super Contributor
    Join Date
    Apr 2007

    Re: Parabolic effect

    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




    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 09:51.

Posting Permissions

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