Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Realistic Basketball Arc

I am writing Open GL using the glut, gl, and glu libraries in Visual C++. I am quite new at this. I am currently doing my first animation. I was wondering if anyone knew a way to program a relatively realistic arc for a basketball. It doesn't have to be too realistic, as I only know the basics, but I thought there might be a way to implement the math library and use a derivation of the following formula (which is the only way I know to create a circle, in 2D):
for (i = 0; i < n; i ++)
{
x = Rad * cos((360 * i)/n) + 100;
y = Rad * sin((360 * i)/n) + 100;

any help would be appreciated...

Comments

  • erezsherezsh Member Posts: 1
    Hi.

    Simply follow physics:
    Px = Px + (Vx / Slowdown)
    Py = Py - (Vy / Slowdown)
    Vy = Vy - g;

    (Px,Py) = Position of ball
    (Vx,Vy) = Velocity
    g = gravity (= 9.8, or anything else u want)
    Slowdown = amount of slowing down the ball...
    ------

    Just use this every frame and the ball will move realisticly...
  • Karl007Karl007 Member Posts: 27
    : Hi.
    :
    : Simply follow physics:
    : Px = Px + (Vx / Slowdown)
    : Py = Py - (Vy / Slowdown)
    : Vy = Vy - g;
    :
    : (Px,Py) = Position of ball
    : (Vx,Vy) = Velocity
    : g = gravity (= 9.8, or anything else u want)
    : Slowdown = amount of slowing down the ball...
    : ------
    :
    : Just use this every frame and the ball will move realisticly...
    :

    Add linear damping (air resistance) and it will be almost perfect :)
    Vx -= damping*Vx
    Vy -= damping*Vy


  • Justin BibJustin Bib USAMember Posts: 0

    _ \ http://forcoder.org \ free ebooks and video tutorials about \ Scratch, Perl, Assembly, PL/SQL, Go, R, Java, C#, Visual Basic .NET, Visual Basic, Delphi, C++, MATLAB, PHP, Python, JavaScript, Swift, Ruby, C, Objective-C SAS, Logo, LabVIEW, Kotlin, ML, Ada, Erlang, COBOL, Prolog, Dart, Lisp, Scheme, Fortran, Transact-SQL, Alice, Lua, Scala, Julia, Clojure, Crystal, Hack, Awk, Bash, FoxPro, Apex, VBScript, Rust, ABAP, D, F# \ ____

Sign In or Register to comment.