Angle calculations are common in game development. Use these formulas to convert between degrees and radians.
Convert Degrees to Radians
1
2
3
| function math.angle2radian(angle)
return angle * math.pi / 180
end
|
Convert Radians to Degrees
1
2
3
| function math.radian2angle(radian)
return radian / math.pi * 180
end
|
For example, math.angle2radian(180) returns π, while math.radian2angle(math.pi / 2) returns 90.