Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pi = math.pi
- function inscribedPoly(_radius,_sides,_units)
- local _angle = (math.pi * (_sides - 2)) / (2 * _sides)
- local _height = math.sin(_angle) * _radius
- local _baseRight = math.cos(_angle) * _radius
- local _area = _height * _baseRight * _sides
- if _units then
- print(_area.." "..tostring(_units).."^2")
- end
- return _area
- end
- function circumscribedPoly(_radius,_sides,_units)
- local _angle = (math.pi * (_sides - 2)) / (2 * _sides)
- local _height = _radius
- local _baseRight = _height / math.tan(_angle)
- local _area = _height * _baseRight * _sides
- if _units then
- print(_area.." "..tostring(_units).."^2")
- end
- return _area
- end
- function sidePoly(_sides,_length,_units)
- local _angle = (math.pi * (_sides - 2)) / (2 * _sides)
- local _baseRight = _length / 2
- local _height = _baseRight * math.tan(_angle)
- local _area = _height * _baseRight * _sides
- if _units then
- print(_area.." "..tostring(_units).."^2")
- end
- return _area
- end
- function area(_radius) return math.pi * (_radius ^ 2) end
- function circumference(_radius) return math.pi * _radius * 2 end
- function diameter(_radius) return _radius * 2 end
- function sphereVolume(_radius) return math.pi * (_radius ^ 3) * (4/3) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement