math.pi
Shared
The mathematical constant pi (π ≈ 3.14159)
Constant
math.pi -- 3.1415926535898Represents the ratio of a circle's circumference to its diameter.
Examples
engine.print("info", math.pi) -- 3.1415926535898local radius = 5
local circumference = 2 * math.pi * radius
engine.print("info", circumference) -- 31.415926535898local radius = 3
local area = math.pi * radius * radius
engine.print("info", area) -- 28.274333882308local point_count = 8
for i = 0, point_count - 1 do
local angle = 2 * math.pi * i / point_count
local pos_x = math.cos(angle)
local pos_y = math.sin(angle)
engine.print("info", pos_x, pos_y)
endlocal radius = 4
local volume = (4 / 3) * math.pi * radius * radius * radius
engine.print("info", volume) -- 268.08257310942local radians = math.pi
engine.print("info", radians) -- 3.1415926535898