A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Get ball path based on angle and start/end point

Hybrid View

  1. #1
    Senior Member
    Join Date
    Nov 2004
    Location
    Amsterdam
    Posts
    212

    Get ball path based on angle and start/end point

    hi,

    If I know the start point and the end point of an object that has been 'launched', for instance a ball has been kicked in the air, and I know the angle with which it has been launched, would it then be possible to (roughly) describe the path that it followed (and the maximum height) and the velocity based on these values?

    Ultimately I'd want to reproduce that path by tweening a line, so that the user can see how he kicked the ball...

    Any tips and ideas and code examples are very welcome,

    thanks,
    Jerry.

  2. #2
    Senior Member
    Join Date
    Nov 2004
    Location
    Amsterdam
    Posts
    212
    Actually i just want to know the maximum height that the ball has reached.

    So the values I know are:
    start point
    end point
    angle of launch

    Is that possible if you don't know the initial velocity?

  3. #3
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    should be possible, let me try to solve it right here...
    assuming you start at x=0, and land at x=r, given cc angle a, you have:
    vy/vx = tan a,
    y = vy * t - g * t * t,
    x = vx * t.
    put 3rd into 2nd:
    y = x tan a - x^2 * (g / vx^2)
    the height would be y when x=r/2:
    h = (r/2) tan a - (r/2)^2 * (g / vx^2)
    now to find (g / vx^2) remember that y(x=r)=0:
    0 = r tan a - r^2 * (g / vx^2)
    or
    (g / vx^2) = (r tan a) / (r^2) = (tan a) / r
    so, finally,
    h = (r/2) tan a - (r/2)^2 * (tan a) / r = (r/2 - r/4) tan a = (r/4) * tan a
    who is this? a word of friendly advice: FFS stop using AS2

  4. #4
    Senior Member
    Join Date
    Jan 2008
    Location
    UK
    Posts
    269
    Looks like you might have meant y = vy * t - 0.5 * g * t * t for that second equation, although you must have corrected it somewhere along the line because the final answer is correct: max height = tan(angle) * range / 4

  5. #5
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    yes, there should be 0.5 - my mistake

    but since the final answer does not include g, it does not matter if you use g or 0.5g or 25g
    who is this? a word of friendly advice: FFS stop using AS2

  6. #6
    Senior Member
    Join Date
    Jan 2008
    Location
    UK
    Posts
    269
    That's right - it's interesting because on first glance at that equation, it looks like the maximum height of a projectile is independent of gravity .... but of course it isn't, because the range is in turn dependent on gravity.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center