Module:Infobox regtemp: Difference between revisions

Fewer parentheses
Preliminary cleanup
Line 38: Line 38:
local data = {}
local data = {}
-- processed mapping
local map = {}
local lowermap = {}
table.insert(data, {
table.insert(data, {
"Subgroups",
"Subgroups",
Line 55: Line 52:
"⟨" .. mapping .. "]"
"⟨" .. mapping .. "]"
})
})
 
-- autocalculating ploidacot
-- process mapping
local map = {}
for num in mapping:gmatch("(%d+); ") do
for num in mapping:gmatch("(%d+); ") do
table.insert(map, num)
table.insert(map, num)
end
end
local ploid = map[1]
local lowermap = {}
for num in mapping:gmatch("(%d+) ") do
for num in mapping:gmatch("(%d+) ") do
table.insert(lowermap, num)
table.insert(lowermap, num)
end
end
-- autocalculating ploidacot
local ploid = tonumber (map[1])
local equave = string.char(string.byte(subgroup, 1))
local equave = string.char(string.byte(subgroup, 1))
Line 101: Line 101:
end
end
local ploidnum = math.log(tonumber(equave))*(1200/math.log(2))/tonumber(ploid)
local equave_size = 1200 * u.log2(tonumber(equave))
local tuningnum = tonumber(tuning)
local period_size = equave_size / ploid
local generator_size = tonumber(tuning)
if cot < 0 then
if cot < 0 then
tuningnum = math.log(tonumber(equave))*(1200/math.log(2)) - tuningnum
generator_size = equave_size - generator_size
cot = math.abs(cot)
cot = math.abs(cot)
end
end
local shear = math.floor(tuningnum*cot/ploidnum)
local shear = math.floor(generator_size*cot/period_size)
shear = math.floor(cot*(shear/cot - math.floor(shear/cot)))
shear = math.floor(cot*(shear/cot - math.floor(shear/cot)))
if cot > 2 then
if cot > 2 and shear == cot - 1 then
if shear == cot-1 then
shear = -1
shear = -1
end
end
end
suffix = p.num2greeklet(tostring(shear)) .. p.num2greek(tostring(cot), "cot") .. suffix
suffix = p.num2greeklet(tostring(shear)) .. p.num2greek(tostring(cot), "cot") .. suffix
if ploid ~= "1" then
if ploid ~= 1 then
suffix = p.num2greek(ploid,"ploid") .. "ploid " .. suffix
suffix = p.num2greek(tostring(ploid), "ploid") .. "ploid " .. suffix
end
end
Line 127: Line 126:
table.insert(data, {
table.insert(data, {
"Edo join",
"Edo join",
"[[" .. edo_first .. "ed" .. equave_letter .. "|" .. edo_first .. "]] &amp; [[" .. edo_second .. "ed" .. equave_letter .. "|" .. edo_second .. "]]"
"[[" .. edo_first .. "ed" .. equave_letter .. "|" .. edo_first .. "]] & [[" .. edo_second .. "ed" .. equave_letter .. "|" .. edo_second .. "]]"
})
})