This project was first inspired by the simulations on the internet. Being able to create a realistic computer graphics that presents motion under laws of physics is pretty impressive for me, so I want to try first making a simple one by myself.

What it does

It'll use a User Interface to take in the user's input, including the fixed acceleration with direction (0 to 360 degrees), the initial velocity with direction, the initial position, and the coefficient of restitution. After clicking the button, it'll show another panel where an object will perform its motion based on the inputs.

How we built it

Using java.awt to build the initial user interface, and use different listener interface to gain inputs from the users. Then, using javax.swing to build up the frame and panel that'll display the animation. Inside the class of panel, there is a Timer and TimerTask that will control the velocity based on acceleration and position, then use these information to calculate the new position and update the position.

Challenges we ran into

When making this project, one problem occurred was to accurately update the position without the influence of rounding error. If the current velocity was too low, then updating with a higher speed (10 ms or less) would cause it to stay at the same position without moving.

Accomplishments that we're proud of

It can present projectile motion on any direction based on the direction of acceleration and initial velocity. Another function is that user can set its own coefficient of restitution, so it can lose some energy when colliding with the edge, being closer to a real world analysis.

What we learned

How to use java.awt and javax.swing to create user interface and graphics. How to use Timer and TimerTask objects to update graphics to create animation.

What's next for 2D Kinematics Simulator

Next we want to add some features that can check the user's input, so the code wouldn't run into errors. Also, we're planning to add air resistance and frictional forces into this simulation.

Built With

Share this project: