Help with pi and trigonometry

In this post it talks about generating a cylinder with code.

local Radius = 1
local Circle = math.pi * 2
local Amt = 10000
local Height = 10

for Y = 0, Height do
	for Number = 1, Amt do
		local Angle = Circle / Amt * Number
		local X = math.sin(Angle) * Radius
		local Z = math.cos(Angle) * Radius

		local Position = Vector3.new(X, Y, Z)
	end
end

For the circle variable, how does multiplying pi by 2 make a circle? To me its just numbers which I have no idea how that represents a circle…

I am also struggling to understand the different formulas that are happening in the for loop, why does it use sin and cos? What does it mean?

Also what does it mean if something is procedurally generated?

Thank you so much if you can help me out

1 Like

Pi in degrees is 180. Si Pi*2 is 360 degrees. 360 degrees in this sense is a circle.

In other words, pi is the radian equivalent of 180 degrees.

2 Likes

You are using radians. Pi is a halfcircle, if you make pi*2 it is like 180*2, you are getting a full circle. Dont ask, it works at this way. This are called radians, if you want more informations you can search on google for the term „radian“. I am sure you will find some information (so use KhanAcademy, it is really helpfull, too)

EDIT:
Yes, I found an post from Khanadacemy about this, you should read it!

This is for pi, for sin and cos you need to understand th eunitcircle, so read it what @SwagMasterAndrew sended

Thank you, how does the formula ‘Angle’ work in the post:

local Angle = Circle / Amt * Number

and why does it use sin and cos, not the other trig functions?

I want to clear up your first question.

A circle doesn’t equal 2π. That doesn’t even make sense. How can a shape equal a number? What it’s saying is that, given a circle of radius 1, the circle’s circumference equals 2π. That is,

C = 2πr

Note that our radius is 1, so it becomes

C = 2π(1) = 2π

So why is C = 2πr in the first place? Well… because it is. π is defined to be the circumference divided by the diameter. AKA

π = C / d

Mathematicians said: “This is what π equals.” And so it is. Continuing our math, if we multiply both sides by d, we have

dπ = C

And we know that the diameter is twice the radius, so d = 2r. Substituting that into the equation, we get

(2r)π = C

Because the radius of a unit circle is 1, this becomes

2π = C

So why is this true? Because we defined it to be that way. The constant π is defined to be C / d, so by definition, C = 2πr.

That begs the question: How do we know that π is 3.14159265…? With big formulas like these which I will not explain because this has gone on long enough.

2 Likes

for sin and cos, i repeat it:

For the formula: I think he is getting the part of the circle (pi*2 = a a full rotation, but you want to maybe form a circle with only 8 parts, you have to divide it by the number of amt you want. Now by multiplying the number it is because you have an unit circle „a circle with diameter 1“, and you are now, multiplying, alyng this to your target circle)

The best method to understand a codesnippet is to ask the codesnippet creator. Send him an PM about asking how the code works (still be polite) and if he want to help you, he will explain it. I had found an codesnippet that i not understod and just asked the creator. Make the same, or try at least

pi is the ratio of a circle’s circumference to it’s diameter. A circle with a radius of 1 (called a unit circle) would have a circumference of 2 * pi.

When you measure an angle in radians, you are essentially using the arc length of that section of the unit circle. A full circle would be 360 degrees and the arc length would be the entire circumference of 2 * pi. A half circle of 180 degrees would be half of the circumference which would be just pi.

Thus the formula for converting between degrees and radians would be:
[radians] = [degrees] * pi / 180
[degrees] = [radians] * 180 / pi

Visualization:
300px-Circle_radians

5 Likes

It is more than likely important to know that the value of math.pi (or pi) is 3.14 (for short), which is the ratio of a circle’s circumference to its diameter. More information can be viewed here.

For the procedurally generated part, basically to make it less complicated, if you know what procedural animation is, it’s like that. But if you don’t, basically making animations via programming, and not an animation editor.

1 Like