How to Graph a Heart Curve in Roblox with Lua

Untitled-1

Untitled-1So  my kid has been playing with Roblox for some time now.  I’m not here to explain what it is, rather this post is specific to graphing mathematical objects in Roblox with Lua scripting.

The video and the code that follows is all that you need to graph a Heart Curve (cardoid) in Roblox using Lua scripting without having to add ANY objects from the toolbox. 

Feel free to check out my Roblox Lua scripts at GitHub.

for x = -1,1,.01 do
local q = math.sqrt(1-x*x)
local y0 = math.sqrt(x*x) - q
local y1 = math.sqrt(x*x) + q
local xa = ((x+1)*160)
local ya = ((y0+1)*100)
local yb = ((y1-1)*100)

print(xa,200-ya)
print(xa,40-yb)
print(yb)
end
 
 

Leave a Reply

Your email address will not be published. Required fields are marked *