Module:Sandbox/Jackmcbarn
Appearance
nil
local p = {}
function p.lambertConformalConic(refLat, refLong, stdParallel1, stdParallel2)
return function(latitude, longitude)
local n
if stdParallel1 == stdParallel2 then
n = math.sin(stdParallel1)
else
n = math.log(math.cos(stdParallel1)/math.cos(stdParallel2))/
math.log(math.tan(0.25*math.pi + 0.5*stdParallel2)/math.tan(0.25*math.pi + 0.5*stdParallel1))
end
local f = math.cos(stdParallel1)*math.tan(0.25*math.pi + 0.5*stdParallel1)^n/n
local rho = f*math.tan(0.25*math.pi + 0.5*latitude)^-n
local rho0 = f*math.tan(0.25*math.pi + 0.5*refLat)^-n
return {
x = rho*math.sin(n*(longitude - refLong)),
y = rho0 - rho*math.cos(n*(longitude - refLong))
}
end
end
function p.pairs(frame)
local args, args_mt = { '__pairs was not used' }, {}
function args_mt.__pairs( t )
return pairs( { 'success' } )
end
return frame:expandTemplate{ title = 'Echo', args = setmetatable( args, args_mt ) }
end
function p.maptest(frame)
local locmap = require('Module:Location map')
local retval = {}
for long=-165,-30,15 do
for lat=40,80,5 do
retval[#retval + 1] = tostring(locmap.mark(frame, {'Canada', long=long, lat=lat, outside='1'}))
end
end
return locmap.top(frame, {'Canada', width=800, float='center'}) .. table.concat(retval) .. locmap.bottom(frame, {'Canada', width=800, float='center'})
end
local function hexToByteTable(str)
local retval = {}
for piece in str:gmatch('[0-9A-Fa-f][0-9A-Fa-f]') do
retval[#retval + 1] = tonumber(piece, 16)
end
return retval
end
local bxor = require('bit32').bxor
local function xorByteTables(t1, t2)
if #t2 < #t1 then
t1, t2 = t2, t1
end
local retval = {}
for k,v in ipairs(t1) do
retval[k] = bxor(v, t2[k])
end
return retval
end
local function byteTableToString(t)
local retval = {}
for k,v in ipairs(t) do
retval[k] = string.char(v)
end
return table.concat(retval)
end
function p.xor(frame)
local s1, s2 = '1f e9 0d d5 33 a4 70 0c 83 03 9b a0 6d 2b', frame.args[1]
local t1, t2 = hexToByteTable(s1), hexToByteTable(s2)
return byteTableToString(xorByteTables(t1, t2))
end
function p.main(frame)
return mw.dumpObject(mw.ustring.match('4', '[^%s%d]'))
end
return p