Skip to content

Instantly share code, notes, and snippets.

@ryan-mooore
Last active June 9, 2021 22:52
Show Gist options
  • Save ryan-mooore/e7a0cf4024b35b0e5bdbdefaf9fdff1c to your computer and use it in GitHub Desktop.
Save ryan-mooore/e7a0cf4024b35b0e5bdbdefaf9fdff1c to your computer and use it in GitHub Desktop.
function You(param) {
if (param == 1) {
height = 30.48*document.running.heightf.value + 2.54*document.running.heighti.value
document.running.heightm.value = height
shoulder = 2.54*document.running.shoulderi.value
document.running.shoulderm.value = shoulder
chest = 2.54*document.running.chesti.value
document.running.chestm.value = chest
}
if (param == 2) {
height = document.running.heightm.value
heightf = Math.floor(height/30.48)
heighti = (height - heightf*30.48)/2.54
document.running.heightf.value = heightf
document.running.heighti.value = heighti
shoulder = document.running.shoulderm.value
document.running.shoulderi.value = shoulder/2.54
chest = document.running.chestm.value
document.running.chesti.value = chest/2.54
}
topside = chest*shoulder
document.running.topside.value = Math.floor(topside)
side = height*chest
document.running.side.value = Math.floor(side)
front = height*shoulder
document.running.front.value = Math.floor(front)
}
function Rain() {
rainspeed = document.running.rainspeed.value
anglef = document.running.anglef.value
angles = document.running.angles.value
frontspeed = rainspeed*Math.tan(anglef*3.14159/180)
sidespeed = rainspeed*Math.tan(angles*3.14159/180)
windspeed = Math.sqrt(frontspeed*frontspeed + sidespeed*sidespeed)
document.running.windspeedm.value = windspeed
document.running.windspeedk.value = windspeed*3.6
document.running.windspeedmiles.value = windspeed*3.6/1.609
}
function YourSpeed() {
yourspeed = document.running.yourspeed.value
distance = document.running.distance.value
document.running.timetaken.value = distance/yourspeed
}
function Calculate() {
height = document.running.heightm.value
shoulder = document.running.shoulderm.value
chest = document.running.chestm.value
topside = chest*shoulder
side = height*chest
front = height*shoulder
rainspeed = document.running.rainspeed.value
anglef = document.running.anglef.value
angles = document.running.angles.value
frontspeed = rainspeed*Math.tan(anglef*3.14159/180)
sidespeed = rainspeed*Math.tan(angles*3.14159/180)
yourspeed = document.running.yourspeed.value
effspeed = yourspeed*1 + frontspeed
distance = document.running.distance.value
time = distance/yourspeed
amount = document.running.amount.value / (10*3600)
tflux = amount // since units are ml=cm^3 and areas are in cm^2
fflux = tflux * effspeed/rainspeed
sflux = tflux * sidespeed/rainspeed
toptotal = tflux * topside * time
sidetotal = sflux * side * time
fronttotal = Math.abs(fflux * front * time)
document.running.fromfront.value = fronttotal
document.running.fromside.value = sidetotal
document.running.fromtop.value = toptotal
document.running.intotal.value = toptotal + sidetotal + fronttotal
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment