I just want to learn some maths in scripting.
Some ones I am desperate to learn that you guys can explain:
math.pi
Multiplication
What do I need to learn about math.pi, multiplication, division, subtraction and addition? If you guys can give me examples what I need to know about them, when to use them, what thing you’re making, and why you use it.
Addition: variable = x + 1
If you want to add 1 (or whatever number) to a variable then use: variable += 1 to do it. Same with subtraction.
Multiplication: variable = x * 2
Division: variable = x / .51234
Most of these functions are self-explanatory, you’ve probably even learned about some of them in school!
But I would say some mathematical concepts you should have an understanding of is Vectors and Quaternions for positions, basic PEMDAS understanding for mathematical expressions, and for math.pi
There are a lot of uses for PI, but what it really is, is just the ratio between the circumference and the diameter of a perfect circle, you can use it to find the area of a circle, a sphere, and many other shapes.
Something else you should have an understanding of is basic trigonometry. Trig is used a lot in programming, especially games. For instance, atan2!
Also, basic dimensional maths like finding perimeters, areas of polygons and distances between points.
u just need to know basic ones (which u learn in like elementary school and a lil from middle?) and for more complex thing just directly search them up google or this forum
Hello sorry for not replying, power is out but can you give me an example of math.pi? Just small code referencing to your response about what math.pi does. Thanks
The CFrame.Angles() function takes three arguments, the x, y, and z rotation to form a CFrame with that rotation with no translation. They are taken in radians, so you could either be lazy and type math.rad(180), but that’s lame. Real programmers would know that 180 in radians is just math.pi. I won’t go into why right now, but that’s just the way it is. So if I wanted to rotate a CFrame by 180 degrees on the Y axis, I could say this:
oldCFrame *= CFrame.Angles(0, math.pi, 0)
And the same logic applies for other angles. Like 90 and 60 degrees, for those I can use math.pi / 2 and math.pi / 3, respectively.