Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can anyone narrow this down for me a little?

I understand it for the most part, however can I ask how math.cos and math.sin are involved, and how a script so minimal can make a complex shape? Thanks.

for i = 0,100, .1 do
 
k=3.8
 
x=(k-1)*math.cos(i)+math.cos((k-1)*i)
y=(k-1)*math.sin(i)-math.sin((k-1)*i)
 
p = Instance.new("Part")
p.CFrame = CFrame.new(Vector3.new(100*x, 100*y, 100))
p.Size = Vector3.new(8,8,8)
p.Anchored = true
p.BottomSurface = "Smooth"
p.TopSurface = "Smooth"
p.Parent = game.Workspace
p.BrickColor = BrickColor.new(26)
 
end

1 answer

✓ Accepted answer

This is more or less the graph of a function x(t) = 2.8 * cos(t) + cos(2.8 * i) and y(t) = 2.8 * sin(i) - sin(2.8 * i ), sometimes called a parameterized function.

First, lets think of a simple graph of a function:

The graph

Over time (horizontally in the picture) the x value (vertically) changes.

The parameterized function does this for both x and y, meaning you have the horizontal and vertical components of the curve moving independently.


cos and sin are almost the same function. They make a wavy line, so they're useful in making interesting looking curves.

1 comment

0

Thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.