# Forum

CS2D Scripts What is math.pi used for?

# What is math.pi used for?

2 replies
Goto Page
1
22.03.20 07:54:43 pm
The kennyS
User
Offline
Hello guys again,
I came up with a math question, I would like to know everything about
math.pi
and how to use it in lua? Probably could some of you give me some examples of using it, please? As far as i know it has a fair connection with
math.rad
,
math.sin
,
math.cos
and
math.tan
.
edited 1×, last 22.03.20 08:04:46 pm
22.03.20 08:13:23 pm
DC
Admin
Offline
math.pi is basically a constant value. The value of pi (3.14159...)
https://en.wikipedia.org/wiki/Pi

It's required for all sorts of trigonometric calculations. Including sin/cos/tan which require an angle in radians in Lua. pi is equal to an angle of 180°. pi/2 is equal to 90° etc.

math.rad converts an angle in degrees to an angle in radians.
math.deg converts an angle in radians to an angle in degrees.

e.g.
math.sin(math.pi)

is equal to
math.sin(math.rad(180))

Also see http://lua-users.org/wiki/MathLibraryTutorial

Additional mathematical background information
https://math.libretexts.org/Bookshelves/Precalculus/Map%3A_Elementary_Trigonometry_(Corral)/04%3A_Radian_Measure/4.01%3A_Radians_and_Degrees
www.UnrealSoftware.de | www.CS2D.com | www.CarnageContest.com | Use the forum & avoid PMs!
23.03.20 09:08:44 am
The kennyS
User
Offline
Thanks DC
1
﻿