Standard ammunition dimensions can be found here.
function ErrMsg( msg ) {
f.Err.value = msg.length == 0 ? "" : " " + msg }
function scan( x , msg ) {
// IE-5.5 converts to 0 both empty strings and strings filled // with whitespace (curse you Bill Gates)
y = x.value // get the input string y.replace( /s/g , "" ) // strip whitespace if ( y.length != 0 ) { y = y - 0 // convert to a number if ( isNaN( y ) ) ErrMsg( "illegible " + msg ) else if ( y <= 0 ) ErrMsg( msg + " must be > 0" ) else { ErrMsg( "" ) return y } } throw NaN }
// inputs var DIA, LEN, FPS, SG
// outputs var TWIST
// var f, which will be document.Calculator, must be declared after the FORM
function InputsOK() {
try { DIA = scan( f.DIA , "Bullet Diameter" ) LEN = scan( f.LEN , "Bullet Length" ) FPS = scan( f.FPS , "Muzzle Velocity") SG = scan( f.SG , "Specific Gravity" ) if ( FPS < 1300 ) { ErrMsg( "LOW Muzzle Velocity!" ) } if ( FPS > 1301 ) { ErrMsg( "OK Muzzle Velocity" ) }
return true } catch ( NaN ) { f.TWIST.value = "" return false } }
function Change() {
if ( ! InputsOK() ) return false
// Bowman: T = 3.5 * V^0.5 * D^2 / L
twist = 3.5 * Math.sqrt( FPS * SG / 10.9 ) * DIA * DIA / LEN
if ( twist < 19.95 ) { // below 20 inches of twist
// round result to nearest 1/10 inch
f.TWIST.value = ( Math.round( twist * 10 ) / 10 ).toFixed( 1 )
} else {
// round result to nearest inch
f.TWIST.value = twist.toFixed()
}
return true // needed to see answer
}
