26 lines
544 B
Lua
26 lines
544 B
Lua
function Calculate_volume(height, angle)
|
|
local r = math.tan(angle) * height
|
|
return 1/3 * math.pi * r^2 * height
|
|
end
|
|
|
|
function Tests()
|
|
-- height, angle
|
|
local cases = {
|
|
{ 4.03, 3.55 },
|
|
{ 308, 380 },
|
|
{ 0.394, 0.826 }
|
|
}
|
|
|
|
for i = 1, #cases do
|
|
local case = cases[i]
|
|
local height = case[1]
|
|
local angle = case[2]
|
|
|
|
local volume = Calculate_volume(height, angle)
|
|
|
|
print(string.format("height: %f, angle: %f, volume: %f", height, angle, volume))
|
|
end
|
|
end
|
|
|
|
Tests()
|