Module:Infobox RT: Difference between revisions

testing out ploidnum
added a lot
Line 71: Line 71:
greek = p.digit2greek(unit, "unit") .. p.digit2greek(decade, "decade")
greek = p.digit2greek(unit, "unit") .. p.digit2greek(decade, "decade")
end
return greek
end
function p.digit2greeklet(number, purpose)
local greek
if number == "1" then
if purpose == "decade" then
greek = "iota-"
elseif purpose == "unit" then
greek = "alpha-"
end
elseif number == "2" then
if purpose == "decade" then
greek = "kappa-"
elseif purpose == "unit" then
greek = "beta-"
end
elseif number == "3" then
if purpose == "decade" then
greek = "lambda-"
elseif purpose == "unit" then
greek = "gamma-"
end
elseif number == "4" then
if purpose == "decade" then
greek = "mu-"
elseif purpose == "unit" then
greek = "delta-"
end
elseif number == "5" then
if purpose == "decade" then
greek = "nu-"
elseif purpose == "unit" then
greek = "epsilon-"
end
elseif number == "6" then
if purpose == "decade" then
greek = "xi-"
elseif purpose == "unit" then
greek = "wau-"
end
elseif number == "7" then
if purpose == "decade" then
greek = "omicron-"
elseif purpose == "unit" then
greek = "zeta-"
end
elseif number == "8" then
if purpose == "decade" then
greek = "pi-"
elseif purpose == "unit" then
greek = "eta-"
end
elseif number == "9" then
if purpose == "decade" then
greek = "qoppa-"
elseif purpose == "unit" then
greek = "theta-"
end
elseif number == "0" then
greek = ""
elseif number == "-1" then
greek = "omega-"
end
return greek
end
function p.num2greeklet(number)
local greek
if string.len(number) == 1 then
greek = p.digit2greeklet(number, "unit")
elseif string.len(number) == 2 then
local unit = string.char(string.byte(number, 2))
local decade = string.char(string.byte(number, 1))
greek = p.digit2greeklet(decade, "decade") .. p.digit2greeklet(unit, "unit")
end
end
return greek
return greek
Line 166: Line 248:
suffix = referent .. suffix
suffix = referent .. suffix
end
end
suffix = p.num2greek(tostring(cot), "cot") .. suffix
local ploidnum = tostring(math.log(tonumber(equave))/tonumber(ploid))
local ploidnum = math.log(tonumber(equave))*(1200/math.log(2))/tonumber(ploid)
local tuningnum = tonumber(tuning)
if cot < 0 then
tuningnum = math.log(tonumber(equave))*(1200/math.log(2)) - tuningnum
cot = math.abs(cot)
end
local shear = math.floor(tuningnum*cot/ploidnum)
shear = math.floor(cot*(shear/cot - math.floor(shear/cot)))
if cot > 2 then
if shear == cot-1 then
shear = -1
end
end
suffix = p.num2greek(ploid,"ploid") .. "ploid " .. p.num2greeklet(tostring(shear)) .. p.num2greek(tostring(cot), "cot") .. suffix
if ploidacot == "cleft" then
ploidacot = suffix
end
-- edo join
-- edo join
Line 188: Line 286:
table.insert(data, {
table.insert(data, {
"Ploidacot",
"Ploidacot",
ploidnum .. suffix
ploidacot
})
})