Paintball Trajectory Calculator

Loading may take awhile, please be patient


Notes On The Trajectory Calculator And Details of Programming

Parameters are changed in the area below the graphs. The velocity, barrel angle spin axis angle (spin direction) and spin can be changed either by using the scrollbars or by typing a number into the adjacent fields. The scrollbars only provide integer input to the calculator, while the fields will allow several decimal places. The spin is controlled by two parameter, the spin angle and the spin velocity. The spin angle varies from -90 to +90 degrees. It is the angle the ball's spin axis makes with the horizontal axis. This can be confusing. Just remember that top spin is 90 degrees, bottom spin is -90 degrees, and 0 degrees represents pure side spin. The latter value causes side deflection of the ball. Lateral deflection can only be viewed to one side.

To start the calculation, hit the Fire button. To stop the calculation, click on the Stop button. You cannot restart a stopped calculation by again hitting the Fire button. The parameters will be reset. The Reset button will reset all parameters to the original values.

There are three graphs that are plotted in real time. The top left large graph is the trajectory of the ball. The second graph just below the first, plots the (side to side) deflection of the ball when spin is invoked. The last graph on the right plots the change in velocity.

Known or possible problems:

This applet will probably not work on Netscape versions 3.0 or lower. It uses a more recent java version (jdk1.2) than the older Netscape versions completely understand. (By the way, its probably time you updated anyway.) It works on Explorer vers. 4.0+. However, it seems to run a bit slower, but the sliders are more stable.

Note that the calculation will appear to slow down as it proceeds. This is due to the way the data is plotting, and is not a calculation problem.

If you have a slow computer or graphics card, the graphs may show strange behavior or not show up properly.

The sliders may do odd things when the mouse is clicked and held down on the slider bar and moved. The bar may continue moving by itself, or jump around. Just click on the bar to settle it down. Most of the problems seem to be with overly fast movements of the bars.


Some Programming Details and Source Code for the Trajectory Program

I include this section strictly for those Java beginners that may find some use in the methods I have used. Also, if someone who is a real programmer ever looks this stuff over and wishes to offer advice on improving it, I would be very grateful.

I do not do programming for a living. All my programming is self taught. Although over the years I have written non OOP code in several programming languages, this was my first over enthusiastic and over ambitious attempt at true OOP programming.

The original program for this calculator was written in the Excel version of Visual Basic and then ported to Java jdk1.2 code. Ha, porting sounds so easy, but it took three books on Java programming, dozens of searches of deja.com and the web, and several months of spare time to bring it all together. I have never had so much trouble learning and understanding a computer language. This OOP stuff was a nightmare. I have indeed learned a great deal and I think I am beginnning to win the war. It is still frustrating, that I don't understand why I had to put certain lines of code in the program. The worst part was setting up the real-time graphics interface. It still is not exactly what I wanted, but it does work. I would caution anyone who wishes to do real time stuff, where what has been placed on a canvas previously must remain there as new stuff is added, to think twice. The most frustrating aspect is that Java must redraw everything, graphs, axis, labels and plots each time I calculate a new number.

Some of the elements in the program that might be useful for others struggling to learn Java like myself are:

*use of GridBagLayout for the entire panel

*the use and mutual updating of scrollbars and textfields depending on where data is entered

*the attempt at real time graph plotting and updating

*the use of multiple canvases in a layout and constant updating them

The source code is provided here for two reasons: One, for those interested in paintball physics, the details of the calculation and especially some of the parameters and coefficients for the drag and lift calculations are documented in the source code and no where else. The second reason, as suggested above is to help aspiring Java programmers. You will find that the code is extensively annotated for both physics and programming. I hope my comments make sense. I got a lot of information from reading the source files of others who were kind enough to provide them on the internet. I hope someone can benefit from my meager offerings. If anyone knows or finds easier ways around some of the things I did, I would very much appreciate hearing from you.

Source code for Trajectory.java

Note that the Trajectory class contains five sub classes embedded in it.

Trajectory is the main class:

BallControls is a subclass that sets up GUI panel, controls and Listeners

Tplot, Lplot, Vplot are extensions of the Canvas class and are used for the graphics.

InfoDialog extends Dialog and is used to bring up a frame if the user inputs data out of range.


All these pages and all graphics are copyrighted (C) 1999 by Gary Dyrkacz unless otherwise noted. Images and programs can be used for personnal, noncommerical interests with the condition that I be acknowledged as author. Use of any images or text for commercial use, or commerical web pages must be arranged with the author.

For more on the what and why of paintball physics start with:

Preamble
Introduction
Trajectory Equations Section
Results Section
Relevance Section
Discussion Section
Conclusions
References
Calculations Section
Java Paintball Trajectory Calculator

Back to Paintball Main Page
Back to Home (WhatEver) Page


Send comments and suggestions to: dyrgcmn@comcast.net

Last Update: December 29, 2006