|
| 24 Dec 2012 01:53 PM |
I've written a polar graphing calculator that graphs using bricks, and it works great. However, it doesn't always seem to graph with the right parameters. You see, I've come up with several equations on my graphing calculator that look like bugs. Here are a few:
Squashed bug: r1=10sin(tan(tan(θ))) Razor-sharp bug: r1=10cos(tan(tan(θ))) Realistic bug: r1=10sin(cos(tan(θ)))
And I graphed all three using this calculator. However, it doesn't look balanced. There's always a part on the left that is missing from the right side, and vice versa, which doesn't happen on my real graphing calculator. I have no idea why. And yes, I'm sure that I'm using the same theta max, min, and step as my calculator is.
function GraphPolar(r1, interpol, min, max, step) min, max, step = min or 0, max or 6.28318, step or .1308 interpol = not not interpol local model = Instance.new("Model") local function convert(r, polar) return Vector3.new(r * math.cos(polar), r * math.sin(polar)) end local function interpolate(p1,p2) p1,p2 = p1.Position, p2.Position local mag = (p1-p2).magnitude for i = 1, mag do local n = Instance.new("Part", model) n.FormFactor = "Symmetric" n.Size = Vector3.new(1,1,1) n.BrickColor = BrickColor.new("Really black") n.Anchored = true n.TopSurface = "Smooth" n.BottomSurface = "Smooth" n.CFrame = CFrame.new(p1:Lerp(p2, i/mag)) Wait() end end local past for POL = min, max, step do local n = Instance.new("Part", model) n.FormFactor = "Symmetric" n.Size = Vector3.new(1,1,1) n.BrickColor = BrickColor.new("Really black") n.Anchored = true n.TopSurface = "Smooth" n.BottomSurface = "Smooth" n.CFrame = CFrame.new(convert(r1(POL), POL)) if interpol and past then interpolate(n, past) end past = n end return model end
local r1 = function(Polar) return 15*math.sin(math.tan(math.tan(Polar))) end local s = GraphPolar(r1, true) s.Parent = Workspace |
|
|
| Report Abuse |
|
|
| 24 Dec 2012 02:01 PM |
| If you try that script without changing a thing, it will take a few seconds for the model to appear in the Workspace. |
|
|
| Report Abuse |
|
|
| 24 Dec 2012 02:30 PM |
| Probably a problem with R.Lua, not you. |
|
|
| Report Abuse |
|