Module:Convert and Module:Convert/sandbox: Difference between pages
Appearance
(Difference between pages)
m 1 revision imported from wikipedia:Module:Convert |
m 1 revision imported |
||
| Line 415: | Line 415: | ||
-- a = (altitude / 5000) rounded to nearest integer (-3 to 80) | -- a = (altitude / 5000) rounded to nearest integer (-3 to 80) | ||
-- s = speed of sound (mph) at that altitude | -- s = speed of sound (mph) at that altitude | ||
-- LATER: Should calculate result from an interpolation between the next | |||
-- lower and higher altitudes in table, rather than rounding to nearest. | |||
-- From: http://www.aerospaceweb.org/question/atmosphere/q0112.shtml | -- From: http://www.aerospaceweb.org/question/atmosphere/q0112.shtml | ||
local mach_table = { -- a = | local mach_table = { -- a = | ||
| Line 427: | Line 429: | ||
672.5, 674.3, 676.1, 677.9, 679.7, 681.5, 683.3, 685.1, 686.8, 688.6, -- 71 to 80 | 672.5, 674.3, 676.1, 677.9, 679.7, 681.5, 683.3, 685.1, 686.8, 688.6, -- 71 to 80 | ||
} | } | ||
local | altitude = altitude or 0 | ||
local a = (altitude < 0) and -altitude or altitude | |||
a = floor(a / 5000 + 0.5) | |||
if altitude < 0 then | |||
a = -a | |||
end | end | ||
if a < -3 then | |||
if | a = -3 | ||
elseif a > 80 then | |||
elseif | a = 80 | ||
end | end | ||
return mach_table[a + 4] * 0.44704 -- mph converted to m/s | |||
end | end | ||
-- END: Code required only for built-in units. | -- END: Code required only for built-in units. | ||
| Line 735: | Line 732: | ||
if not success then return false, result end | if not success then return false, result end | ||
override_from(result, t, { 'customary', 'default', 'link', 'symbol', 'symlink', 'usename' }) | override_from(result, t, { 'customary', 'default', 'link', 'symbol', 'symlink', 'usename' }) | ||
local multiplier = t.multiplier | local multiplier = t.multiplier | ||
if multiplier then | if multiplier then | ||