generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Graphing Polar Equations

Previous Thread :: Next Thread 
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
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
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
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
FlamedSkull is not online. FlamedSkull
Joined: 23 May 2009
Total Posts: 1379
24 Dec 2012 02:30 PM
Probably a problem with R.Lua, not you.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image