# Explain for me how math.sin (), math.cos () works

i dont know how math.sin() , math.cos() works someone explain for me pls

5 Likes

Those are functions which â€śtranslateâ€ť angles to side lengths of right triangles.

3 Likes

`math.sin()` and `math.cos()` are built in math functions which represent the math functions Sine and Cosine. These two functions are called trigonometric functions which are all related to right triangles. Main use case as @NachtHemd mentioned is to relate a triangleâ€™s angles to itâ€™s sides.

Another useful use for sine and cosine is their usages to make waves. When graphed these two functions will create a repeating wave pattern that has a variable input.

This website will help explain and give visuals to all of this.

12 Likes

Additionally, the functions do not run on degrees but radians. They run on `math.rad(x)`, where `x` is degrees, which is converted to radians.

2 Likes

This is a case where school actually does something for you lol. Try solving some trig right angle problems online, and they will give u the understanding of how it works.

4 Likes

Yeah, the uses of it are too many and explaining what they do here probably wonâ€™t lend OP anything useful - I agree.

Itâ€™s more of a â€śwhen you need it, you will knowâ€ť once you educate yourself on some example problems and learning what they solve in relation to triangles and circular functions.

3 Likes

Out of all the resources I tried, KhanAcademy worked the best at teaching me trigonometry, especially unit circles!

1 Like

mate Iâ€™ve been reading forums and wikis for the past few days trying to figure out why my math.sin and math.cos have been acting weird, now i found out you have to use them with radians, youâ€™re my saviour.

i think the best way to understand sin is to plot it on a graph

you can do that at Graphing Calculator

so you can see that sin is a wave that goes upto 1 and then back down to -1

you can also see that sin starts at 0 then at 3.1415926536(pi) goes back to 0

there is also math.cos

cos is the same as sin but simply offset so unlike sin starts at 1 instead of 0

so one cool thing you can do with sin and cos is make circles like this

``````local amount = 40
local offset = math.pi * 2 / amount

for i = 1, amount do
local part = Instance.new("Part")
-- use sin and cos to position the parts in a circle
part.position = Vector3.new(math.sin(i * offset) * 10, math.cos(i * offset) * 10, 0)
part.Size = Vector3.new(1, 1, 1)
part.Anchored = true
part.Parent = game.Workspace
end
``````

here is another post asking the same thing What is math.sin

6 Likes