Forum

> > CS2D > Scripts > What is math.pi used for?
Forums overviewCS2D overview Scripts overviewLog in to reply

English What is math.pi used for?

2 replies
To the start Previous 1 Next To the start

old What is math.pi used for?

The Dark Shadow
User Off Offline

Quote
us 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

old Re: What is math.pi used for?

DC
Admin Off Offline

Quote
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
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview