Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What makes math.pi so important for rotations ... etc...?

Asked by 9 years ago

What makes math.pi so important for rotations ... etc...?

2 answers

Log in to vote
7
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

Math, and consequently computers, doesn't use degrees for measuring angle.

While degrees are relatively useful for humans to understand angle, they are inelegant mathematically.

Mathematics uses the unit of radians for the measurement of a circle. There are two pi radians in a full circle. In other words, 360 degrees is 2pi radians, 180 degrees is pi radians, 30 degrees is pi / 3 radians, etc.

If you want to convert between radians and degrees, Lua have a function for you:

local radians = math.rad( degrees )
local degrees = math.deg( radians )

Imagine the unit circle, radius 1. In radians, the length of the arc moving around the circle is the same as the angle: C = pi * D = pi * 2r, as I'm sure you learned a long time ago. If you go 1/5 of the way around the circle, you've covered 360 / 5 degrees, while covering 2pi / 5 radians and 2pi / 5 of the arc length of the circumference.

Radians make cos and sin nicer to work with (mathematically), especially in calculus. In Lua, math.cos, math.sin, math.tan, math.asin, etc all use radians instead of degrees.


EDIT: Added a 2 I was missing

0
Thankyou so much. Blockeus 68 — 9y
Ad
Log in to vote
2
Answered by 9 years ago

Circles

In lots of math, especially dealing with circles and certain other shapes such as ellipses. Let's say you wanted to make a function that got the circumference of a circle.

To do this, we'd have to use math.pi in our calculations.

function getCircumference(rad)
local pi = math.pi;
local radius = rad;
local circum = (2*radius*pi)
return circum;
end

print(getCircumference(5))
--31.415926535898

Trigonometry

In Trigonometry, Pi is used ALOT when dealing with radii.

A full circle in radii is actually (2*pi) while half a circle is (pi)

For example, let's make a function that takes degrees and converts it to radii [Without using the math.deg built-in method]

function degToRad(degr)
    return (degr*math.pi/180)
end

print(degToRad(360))
--6.28 which is equivalent to 2(pi)

Although I won't get into the trigonometric functions for now [sin,cos,tan,cot,sec,cosec] : Using pi and radii becomes a HUGE part of trigonometry if you take it in school soon.

Integration

When dealing with integrals [Calculus] pi is also used to describe definite integrals used to describe the calculations of the circumference, area, or volume of shapes made by circles.


Spheres

When dealing with spheres [basically 3D circles], you also need pi.

Say we wanted to make a function to get the volume of a sphere; you'd see that pi is used in a similar fashion as to circles:

function areaSphere(rad)
return (4*math.pow(rad,2)*math.pi)
end

print(areaSphere(10))
--1256.6370614359

Usage

Pi is used a lot in mathematics. It is essential in many problems that deal with specific shapes with round lines and so on. I can't even begin to describe everything it's used in, but rather I tried to give some common applications of it.


Facts

-pi is irrational [It can't be written as a fraction]

-No end has been found for pi [As a result of its irrationality]

-pi is normally approximated in many situations just as 3.14

-pi is actually great to work with when you learn how to use it since you realize that most of the time, you'll find yourself cancelling it out in many equations


If you have any comments or concerns, don't hesitate to comment!

2
"No end has been found for pi" This is a trivial result of it being irrational. But it's also a result of it not being a fraction with a denominator made of products of 2s and 5s... You say "normally calculated" when you mean "normally approximated as". BlueTaslem 18071 — 9y
0
Edited, thank you. DigitalVeer 1473 — 9y

Answer this question