Nautical/Flight Functions:
Ten functions performing nautical/Flight conversion calculations
Description:
The Nautical/Flight functions perform various calculations useful for planning trips. The definitions and arguments of each function is below.
Syntax:
double = MPHToKt(milesperhour)
double = KtToMPH(knots)
double = miToNautMi(miles)
double = nautMiToMi(nauticalMiles)
double = minsInFlight(nauticalMiles, knots)
double = nautMiFlown(knots, minutes)
double = ktSpeed(nauticalMiles, minutes)
double = hrMins(hours)
double = sdMins(seconds)
double = galFuel(minutes, gallonsPerHour)
Details:
miles per hour to knots ----------------------- function name: MPHToKt purpose: converts miles per hour to knots arguments: mph miles per hour as double returns: double
knots to miles per hour ----------------------- function name: KtToMPH purpose: converts knots to miles per hour arguments: knots knots as double returns: double
miles to nautical miles ----------------------- function name: miToNautMi purpose: converts miles to nautical miles arguments: miles miles as double returns: double
nautical miles to miles ----------------------- function name: nautMiToMi purpose: converts nautical miles to miles arguments: nauticalmiles nautical miles as double returns: double
flight time in minutes ----------------------- function name: minsInFlight purpose: calculates total flight time in minutes arguments: nauticalmiles nautical miles to travel as double knots air speed in knots as double returns: double
nautical miles flown ----------------------- function name: nautMiFlown purpose: calculates the nautical miles flown arguments: knots air speed in knots as double minutes minutes elapsed as double returns: double
average speed in knots ----------------------- function name: ktSpeed purpose: calculates the average speed in knots arguments: nauticalmiles nautical miles travelled as double minutes minutes elapsed as double returns: double
hours to minutes ----------------------- function name: hrMins purpose: converts hours to minutes arguments: hour hours as double returns: double
seconds to minutes ----------------------- function name: sdMins purpose: converts seconds to minutes arguments: seconds seconds as double returns: double
gallons of fuel needed ----------------------- function name: galFuel purpose: calculates the minimum number of gallons of fuel needed for a given trip time. arguments: minutes minutes as double gallonsPerHour gallons per hour consumed by craft as double returns: double
Example:
<%
Dim distance, traveltime, calcAvgSpeed, calcFlightTime Dim calcDistance, calcMiles Const GallonsConsumedPerHour = 2900 'gallons/hour - avg for a 747 aircraft
distance = MiToNautMi(400) traveltime = 45 ' minutes calcAvgSpeed = ktSpeed(distance, traveltime) 'knots calcFlightTime = MinsInFlight( distance , calcAvgSpeed) 'minutes calcDistance = nautMiFlown(calcAvgSpeed, calcFlightTime) 'nautical miles calcMiles = NautMiToMi(calcDistance) 'miles calcFuel = galFuel(calcFlightTime, GallonsConsumedPerHour) 'gallons
Response.Write "average speed: " & calcAvgSpeed & " knots" Response.Write "average flight time: " & calcFlightTime & " minutes" Response.Write "average distance travelled: " & calcDistance & " nautical miles" Response.Write "average distance travelled: " & calcMiles & " miles" Response.Write "estimated fuel consumed: " & calcFuel & " gallons"
'--- returns: '--- average speed: 463.455176840407 knots '--- average flight time: 45 minutes '--- average distance travelled (knots): 347.591382630306 nautical miles '--- average distance travelled (miles): 400 miles '--- estimated fuel consumed: 2175 gallons
%>
ASP Source Code:
<%
'--- miles per hour to knots Private Function MPHToKt(ByVal mph) MPHToKt = cdbl(cdbl(mph) / 1.152) End Function
'--- knots to miles per hour Private Function KtToMPH(ByVal kt) KtToMPH = cdbl(1.152 * cdbl(Kt)) End Function
'--- miles to nautical miles Private Function miToNautMi(ByVal miles) MiToNautMi = cdbl((cdbl(miles) * 5280) / 6076.1) End Function
'--- nautical miles to miles Private Function nautMiToMi(ByVal nautMi) NautMiToMi = cdbl((cdbl(nautMi) * 6076.1) / 5280) End Function
'--- flight time in minutes Private Function minsInFlight(ByVal nautMi, ByVal kt) MinsInFlight = cdbl((cdbl(nautMi) / cdbl(kt)) * 60) End Function
'--- nautical miles flown Private Function nautMiFlown(ByVal kt, ByVal mins) NautMiFlown = (cdbl(mins) / 60) * cdbl(cdbl(kt)) End Function
'--- average speed in knots Private Function ktSpeed(ByVal nautMi, ByVal mins) ktSpeed = cdbl(cdbl(nautMi) / (cdbl(mins) / 60)) End Function
'--- hours to minutes Private Function hrMins(ByVal hr) hrMins = cdbl(cdbl(hr) * 60) End Function
'--- seconds to minutes Private Function sdMins(ByVal sd) sdMins = cdbl(cdbl(sd) / 60) End Function
'--- gallons of fuel needed Private Function galFuel(ByVal mins, ByVal gph) galFuel = cdbl((cdbl(mins) / 60) * gph) End Function
%>
|