Engineering >> Computer Science & EngineeringProgramming a Basketballby Aaron Daniel
Submitted : Spring 2014 A program using the Java programming language, constructed within a Java integrated development environment called Netbeans, consists of two graphical sliders, which are used to obtain the velocities of the basketball’s movement; two objects, which are represented by the basketball and basket; and a timer. Using these, the determination of the two initial velocities in either the x- and y-direction were obtained through the user’s input. Given these initial velocities, the program creates the velocity equations in the form of: Vx(t) = Vxi + Ax * t Vy(t) = Vyi + Ay * t
Having these two velocities inputted starts the timer, which is used to move the ball and show its movement throughout the program. Every time the timer ticks the program uses the basic definition of an integral, being the area under a curve, to find the next position of the basketball. Taking the area under the velocity equations every 0.1 seconds, multiplying that to the value of the velocity function, and adding that value to the previous position of the basketball will result in the next position of the basketball so on and so forth until the program terminates the balls movement.
|