Wednesday, December 21, 2011

A Physics Example in Java: A Projectile Fired from a Cannon, 2D Particle Kinematics

Here is an example program that shows how to implement kinematic equations for projectile motion using Java and the Swing 2D graphics libraries.

Equation used to plot projectile path along the X and Y axis

The Java code for these equations are simple, here is the current implementation of the doSimulation routine. The routine calculates the X and Y positions of the projectile over time.  The project only consists of two classes, the class for rendering the simulation and initializing the application.  The other class contains logic for calculating the X and Y positions.

Java code, DoSimulation routine, see s.i and s.k for the X/Y positions





Java 2D Cannon Physics Simulation

Java Source

https://jvmnotebook.googlecode.com/svn/trunk/blog/java/SimpleCannonPhysicsJava


Based on code from: physics for game developers, David Bourg

http://berlin2research.com/dyna/berlinbrown_java_resume/

----

So today we see man a highly evolved creature who not only acts but thinks and feels. All these thoughts, feelings and emotions are interrelated.
The body and the mind of man are so closely bound together that whatever affects one affects the other. An instantaneous change of mind instantly changes the muscles of the face. A violent thought instantly brings violent bodily movements.

2 comments:

jacob lee said...
This comment has been removed by the author.
andy adams said...

YSYou are excellent. Your post about how to implement kinematic equations for projectile motion using Java and the Swing 2D graphics libraries is in very details.
In a word,i'm just new to java.I met a lot of problems in my work,your article is written very well, there is a lot of very useful knowledge to help me solve problems.I enjoy reading your article and hope to see more.




Labels: Java Source Software Development Java Barcode Kinematic Equations