Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Can anyone narrow this down for me a little?

Asked by
bloxxyz 274 Moderation Voter
10 years ago

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

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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.

0
Thanks. bloxxyz 274 — 10y
Ad

Answer this question