What is math.sin, what does it do?, if so can give examples please?, i already read devhub but i dont seem to get it
Sine (abbreviated sin) is a trigonometric mathematical operation. math.sin(x) simply returns the sine of x in radians (basically another version of degrees).
If you want to learn more about what it means to find the sine of something in general, check out some videos on YouTube.
amount of sins you commited in math
math.sin( x )
Returns the sine of x (assumed to be in radians).
or just look up roblox math.sin
Examples That includes radians?
This text will be blurred
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
maths.pi simply is the value 3.1415926536…
And why are you multiplying it by 2 and dividing it by the amount?, also, this can be calculated on a calculator too?, offset of what?
pi = 3.1415926536
pi * 2 = 6.2831853072
if you look at the graph you can see the wave does a full up and down wave at
6.2831853072(pi * 2)
so thats why i do pi * 2
and i divide it by amount to work out how many parts to fit into the circle
Oh i see, i dont know what i did here, but i changed sin(x) to this and the offset of the graph changed
Please refer:
https://developer.roblox.com/en-us/api-reference/lua-docs/math
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 such as 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.
Resources:
That doesnt seems like a circle
Wow that does make it much easier to understand
that’s correct you don’t need to use sin for circles but its one thing you can use it for
its very versatile
but if you do want to use it for circles
here is another example
local part = Instance.new("Part")
part.Size = Vector3.new(1, 1, 1)
part.Anchored = true
part.Parent = game.Workspace
local i = 0
while true do
part.position = Vector3.new(math.sin(i) * 20, 0, math.cos(i) * 20)
i += task.wait()
end