{"id":244,"date":"2009-04-05T21:58:08","date_gmt":"2009-04-06T04:58:08","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1116"},"modified":"2009-04-05T21:58:08","modified_gmt":"2009-04-06T04:58:08","slug":"tooth-curve-modified-bicuspid","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=244","title":{"rendered":"Tooth Curve (modified Bicuspid)"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar canvas:BitmapData=new BitmapData(400,400,false,0xCCCCCC);\r\naddChild(new Bitmap(canvas));\r\n\r\nvar a:Number=-1.21;\r\nvar r:Rectangle=new Rectangle(0,0,3,5);\r\nvar halfWidth:Number=canvas.width\/2;\r\nvar halfHeight:Number=canvas.height\/2;\r\n\r\nrender();\r\n\r\nfunction render():void{\r\n\tfor (var x:Number = -2; x&lt;=2; x+=.05) {\r\n\t\tfor (var y:Number = -2; y&lt;=2; y+=.05) {\r\n\t\r\n\t\t\t\/\/ equation from : http:\/\/en.wikipedia.org\/wiki\/Bicuspid_curve\r\n\t\t\t\/\/(x^2 - a^2) * (x - a)^2 + (y^2 - a^2) * (y^2 - a^2) = 0\r\n\t\r\n\t\t\t\/\/ unpoptimized:\r\n\t\t\t\/\/ var e:Number = (x*x - a*a) * (x-a)*(x-a) + (y*y-a*a) * (y*y-a*a);  \r\n\t\t\t\/\/ optimized:\r\n\t\t\tvar x_a:Number=x-a;\r\n\t\t\t\/\/ factoring: x^2 - a^2 = (x + a) * (x - a)\r\n\t\t\tvar y2_a2:Number =  (y + a) * (y - a);\r\n\t\t\tvar e:Number = (x + a) * x_a * x_a * x_a +  y2_a2 * y2_a2;\r\n\t\r\n\t\t\t\/\/ tolerance beetween .7 &amp; -.1;\r\n\t\t\tif (e&lt;.7&amp;&amp;e&gt;-.1) {\r\n\t\t\t\tr.x=halfWidth+y*50;\r\n\t\t\t\tr.y=halfHeight-x*100;\r\n\t\t\t\tcanvas.fillRect(r, 0x000000);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>I&#8217;ve been looking for a single math equation to draw a tooth for sometime&#8230;. today I stumbled upon <a href=\"http:\/\/en.wikipedia.org\/wiki\/Bicuspid_curve\">this<\/a>&#8230; and realized it could probably be changed to look more like a tooth.<\/p>\n<p>This snippet will draw this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/actionsnippet.com\/wp-content\/tooth_curve.gif\" \/><\/p>\n<p>I&#8217;m using a graphing method here that allows me to use the Cartesian form of the equation and not the parameteric&#8230; I&#8217;ll explain a bit more about this in a later post.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>var canvas:BitmapData=new BitmapData(400,400,false,0xCCCCCC); addChild(new Bitmap(canvas)); var a:Number=-1.21; var r:Rectangle=new Rectangle(0,0,3,5); var halfWidth:Number=canvas.width\/2; var halfHeight:Number=canvas.height\/2; render(); function render():void{ for (var x:Number = -2; x&lt;=2; x+=.05) { for (var y:Number = -2; y&lt;=2; y+=.05) { \/\/ equation from : http:\/\/en.wikipedia.org\/wiki\/Bicuspid_curve \/\/(x^2 &#8211; a^2) * (x &#8211; a)^2 + (y^2 &#8211; a^2) * (y^2 &#8211; a^2) = 0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,121],"tags":[3,4],"class_list":["post-244","post","type-post","status-publish","format-standard","hentry","category-bitmapdata","category-math","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=244"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/244\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}