I have a script for the Roblox version of Lua. Roblox's syntax checking system says that there is nothing wrong with my script. The script is supposed to create a graph of a circle using 'Parts' or 'Bricks'. Below is the wiki page I got the graph function from.
I think bounds.from is the current position of the brick; bounds.to is the next calculated position of the next brick; bounds.step is the counter for what step is being taken - meaning you can change the resolution of the graph (Like 1,000 points or 10,000 points)
Wiki page for graph function. The 'Making a Grapher' is what I used.
local p = Instance.new("Part")
p.Anchored = true
p.BottomSurface = "Smooth"
p.TopSurface = "Smooth"
p.BrickColor = BrickColor.Black()
p.FormFactor = "Custom"
p.Size = Vector3.new(1, 1, 1)
function graph(bounds, f)
bounds.step = bounds.step or (bounds.max - bounds.min) / bounds.n
for t = bounds.from, bounds.to, bounds.step do
local xyz = f(t)
local p = p.clone()
p.CFrame = CFrame.new(xyz)
p.Parent = game.Workspace
end
end
graph({from = 0, to = math.pi * 12, n = 1000}, function(t)
return Vector3.new(
5 * math.cos(t),
5 * math.sin(t),
0
)
end)
PS: I am in Algebra 1 so I don't know sines, cosines, and tangents nor parametric equations.