{"id":1020,"date":"2014-10-10T21:23:09","date_gmt":"2014-10-10T13:23:09","guid":{"rendered":"http:\/\/www.storagelab.org.cn\/zhangdi\/?p=1020"},"modified":"2014-10-10T21:23:09","modified_gmt":"2014-10-10T13:23:09","slug":"d3%e5%8f%af%e8%a7%86%e5%8c%96%e5%ae%9e%e6%88%9803%ef%bc%9a%e7%a5%9e%e5%a5%87%e7%9a%84superformula","status":"publish","type":"post","link":"https:\/\/www.divis.cn\/index.php\/2014\/10\/10\/d3%e5%8f%af%e8%a7%86%e5%8c%96%e5%ae%9e%e6%88%9803%ef%bc%9a%e7%a5%9e%e5%a5%87%e7%9a%84superformula\/","title":{"rendered":"d3\u53ef\u89c6\u5316\u5b9e\u621803\uff1a\u795e\u5947\u7684superformula"},"content":{"rendered":"<h2>\u9700\u6c42\u9a71\u52a8\u5b9e\u73b0<\/h2>\n<p>\u524d\u6587\u8bb2\u8fc7\u4e86D3\u7684\u6570\u636e\u9a71\u52a8\u673a\u5236\uff0c\u4e2d\u95f4\u6240\u4e3e\u7684\u4f8b\u5b50\u90fd\u5f88\u7b80\u5355\u3002\u4f8b\u5982\u90a3\u4e2a<a href=\"http:\/\/runjs.cn\/detail\/8enw0npq\">demo<\/a>\u91cc\u9762\uff0c\u7ed1\u5b9a\u7684\u6570\u636e\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6570\u7ec4\uff0c\u5b9e\u73b0\u7684\u56fe\u5143\u4e5f\u4ec5\u4ec5\u662f\u4e00\u5806\u7528SVG\u753b\u7684circle\u3002\u4f46\u662f\u73b0\u5b9e\u4e16\u754c\u4e2d\u6211\u4eec\u5f80\u5f80\u4f1a\u9047\u5230\u590d\u6742\u7684\u9700\u6c42\uff0c\u4f8b\u5982\u6211\u5c31\u9047\u5230\u4e86\u8fd9\u6837\u4e00\u4e2a\u9700\u6c42\uff1a\u6570\u636e\u662f\u4e00\u4e2a\u590d\u6742\u7684\u5bf9\u8c61\u6570\u7ec4\uff0c\u800c\u4e0e\u4e4b\u7ed1\u5b9a\u7684\u56fe\u5143\u662f\u4e00\u4e2a\u53ef\u53d8\u56fe\u5f62\u3002\u8be5\u56fe\u5f62\u53ef\u4ee5\u6839\u636e\u4e0e\u4ed6\u7ed1\u5b9a\u7684\u6570\u636e\u4e2d\u7684\u5177\u4f53\u53c2\u6570\uff0c\u5728\u5706\u5f62\u3001\u65b9\u5757\u3001\u4e09\u89d2\u4e4b\u95f4\u5207\u6362\uff0c\u5e76\u4e14\u8981\u6c42\u8fc7\u6e21\u81ea\u7136\u3002<\/p>\n<p>\u9762\u5bf9\u8fd9\u4e2a\u9700\u6c42\uff0c\u6700\u76f4\u63a5\u7684\u505a\u6cd5\u662f\u628a\u5706\u5f62\u3001\u65b9\u5757\u3001\u4e09\u89d2\u7528SVG\u7684&lt;circle&gt;\u5706\u5f62\u6807\u7b7e\uff0c&lt;rect&gt;\u77e9\u5f62\u6807\u7b7e\u4ee5\u53ca&lt;polygon&gt;\u591a\u8fb9\u5f62\u6807\u7b7e\u6765\u5206\u522b\u5b9e\u73b0\u3002\u5177\u4f53\u7528D3\u5b9e\u73b0\uff0c\u5c31\u662f\u521b\u5efa\u4e00\u4e2a&lt;g&gt;\u96c6\u5408\u6807\u7b7e\u4f5c\u4e3a\u6570\u636e\u7ed1\u5b9a\u5bf9\u8c61\uff0c\u6839\u636e\u6570\u636e\u53c2\u6570\u7684\u53d8\u5316\uff0cremove\u91cc\u9762\u7684\u539f\u6709\u56fe\u5f62\uff0cadd\u65b0\u7684\u56fe\u5f62\uff0c\u4ece\u800c\u5b9e\u73b0\u6570\u636e\u9a71\u52a8\u7684\u56fe\u5f62\u66f4\u65b0\u3002\u4f46\u662f\u8fd9\u79cd\u65b9\u6cd5\u6709\u4e00\u4e2a\u5f88\u96be\u89e3\u51b3\u7684\u95ee\u9898\uff0c\u5c31\u662f\u56fe\u5f62\u5207\u6362\u65f6\u7684\u8fc7\u6e21\u52a8\u753b\u5f88\u96be\u5e73\u6ed1\u3002\u56e0\u4e3a\u6bcf\u4e2a\u56fe\u5f62\u90fd\u662f\u72ec\u7acb\u7684\u6807\u7b7e\uff0c\u9664\u4e86\u91c7\u7528\u6de1\u5165\u6de1\u51fa\u4e4b\u7c7b\u7684\u8fc7\u6e21\u65b9\u6cd5\u5916\uff0c\u5f88\u96be\u60f3\u5230\u6709\u4ec0\u4e48\u66f4\u597d\u7684\u8fc7\u6e21\u6548\u679c\u3002\u5e76\u4e14\u51fa\u4e8e\u5bf9\u4ee3\u7801\u7b80\u5316\u7684\u8003\u8651\uff0cg\u6807\u7b7e\u5185\u5305\u88f9\u5176\u4ed6\u7684\u56fe\u5f62\u6807\u7b7e\u7684\u65b9\u5f0f\uff0c\u4e5f\u589e\u52a0\u4e86\u590d\u6742\u5ea6\u3002<\/p>\n<p>\u90a3\u4e48\u8fd8\u6709\u5176\u4ed6\u65b9\u6848\u5417\uff1f\u5982\u679c\u80fd\u6709\u4e00\u4e2a\u4e07\u80fd\u56fe\u5f62\u6807\u7b7e\u6765\u6765\u5b9e\u73b0\u5404\u79cd\u56fe\u5f62\uff0c\u628a\u6570\u636e\u76f4\u63a5\u7ed1\u5b9a\u7ed9\u5b83\uff0c\u90a3\u5c31\u518d\u597d\u4e0d\u8fc7\u4e86\u3002\u4e8b\u5b9e\u4e0aSVG\u7684&lt;path&gt;\u8def\u5f84\u6807\u7b7e\u5c31\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u4e00\u70b9\u3002\u5728\u6211\u4e4b\u524d\u7684\u6587\u7ae0&#8221;<a href=\"http:\/\/www.storagelab.org.cn\/zhangdi\/2014\/09\/08\/d3%E5%8F%AF%E8%A7%86%E5%8C%96%E5%AE%9E%E6%88%9801%EF%BC%9A%E7%90%86%E8%A7%A3svg%E5%85%83%E7%B4%A0%E7%89%B9%E6%80%A7\/\">d3\u53ef\u89c6\u5316\u5b9e\u621801\uff1a\u7406\u89e3SVG\u5143\u7d20\u7279\u6027<\/a>&#8220;\u4e2d\u5df2\u7ecf\u63d0\u5230\uff0c\u8def\u5f84\u529f\u80fd\u975e\u5e38\u5f3a\u5927\u51e0\u4e4e\u53ef\u4ee5\u63cf\u7ed8\u4efb\u4f55\u56fe\u5f62\u3002\u552f\u4e00\u7684\u95ee\u9898\u662f\uff0c\u5982\u4f55\u6307\u5b9aPath\u7684\u5177\u4f53\u53c2\u6570\u3002\u5bf9\u4e8e\u4e00\u822c\u60c5\u51b5\uff0c\u6211\u4eec\u53ef\u4ee5\u81ea\u5df1\u8bbe\u5b9a\u53c2\u6570\u3002\u800c\u5728\u8fd9\u91cc\uff0c\u6211\u6253\u7b97\u7528\u4e00\u4e2a\u6570\u5b66\u6a21\u578b\u6765\u6307\u5b9apath\u7684\u5177\u4f53\u53c2\u6570\uff0c\u90a3\u5c31\u662f<a href=\"http:\/\/en.wikipedia.org\/wiki\/Superformula\">superfomula<\/a>\u8d85\u7ea7\u65b9\u7a0b\u5f0f\u3002\u6700\u7ec8\u5b9e\u73b0\u7684\u6548\u679c\u679c\u7136\u975e\u5e38\u597d\uff0c\u52a8\u753b\u8fc7\u6e21\u975e\u5e38\u5e73\u6ed1\uff0c\u56fe\u5143\u672c\u8eab\u4e5f\u5f88\u7b80\u5355\u3002\u4e0b\u9762\u8ba9\u6211\u4eec\u770b\u770b\u8fd9\u4e2a<a href=\"http:\/\/en.wikipedia.org\/wiki\/Superformula\">superfomula<\/a>\u7a76\u7adf\u662f\u4f55\u65b9\u795e\u5723\u5427\u3002<\/p>\n<h2>about\u8d85\u7ea7\u65b9\u7a0b\u5f0f<\/h2>\n<p><a href=\"http:\/\/www.storagelab.org.cn\/zhangdi\/2014\/10\/01\/d3%e5%8f%af%e8%a7%86%e5%8c%96%e5%ae%9e%e6%88%9803%ef%bc%9a%e7%a5%9e%e5%a5%87%e7%9a%84superformula\/superfomula3d\/\" rel=\"attachment wp-att-1096\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1096\" alt=\"superfomula3D\" src=\"http:\/\/www.storagelab.org.cn\/zhangdi\/files\/2014\/10\/superfomula3D.jpg\" width=\"938\" height=\"525\" \/><\/a><\/p>\n<p>\u6211\u4eec\u77e5\u9053\uff0c\u5f88\u591a\u6570\u5b66\u51fd\u6570\u90fd\u53ef\u4ee5\u7528\u89e3\u6790\u5f0f\u7684\u65b9\u5f0f\u8868\u793a\uff0c\u4ea6\u53ef\u6839\u636e\u53d8\u91cf\u548c\u81ea\u53d8\u91cf\u7684\u503c\u5728\u4e0d\u540c\u5750\u6807\u7cfb\u4e0b\u7ed8\u6210\u5404\u79cd\u56fe\u5f62\u3002Johan Gielis\u535a\u58eb\u63d0\u51fa\u4e86\u4e00\u4e2a\u51fd\u6570\uff0c\u53ef\u4ee5\u63cf\u8ff0\u81ea\u7136\u754c\u4e2d\u53d1\u73b0\u7684\u4f17\u591a\u590d\u6742\u56fe\u5f62\u548c\u66f2\u7ebf\uff0c\u5b83\u5c31\u662f\u8d85\u7ea7\u65b9\u7a0b\u5f0f<a href=\"http:\/\/en.wikipedia.org\/wiki\/Superformula\">superfomula<\/a>\u3002<\/p>\n<p>\u8d85\u7ea7\u65b9\u5f0f\u7684\u89e3\u6790\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" alt=\"r\\left(\\varphi\\right) =&lt;br \/&gt;&lt;br \/&gt;&lt;br \/&gt; \\left[&lt;br \/&gt;&lt;br \/&gt;&lt;br \/&gt;         \\left|&lt;br \/&gt;&lt;br \/&gt;&lt;br \/&gt;                 \\frac{\\cos\\left(\\frac{m\\varphi}{4}\\right)}{a}&lt;br \/&gt;&lt;br \/&gt;&lt;br \/&gt;         \\right| ^{n_{2}}&lt;br \/&gt;&lt;br \/&gt;&lt;br \/&gt; +&lt;br \/&gt;&lt;br \/&gt;&lt;br \/&gt;         \\left|&lt;br \/&gt;&lt;br \/&gt;&lt;br \/&gt;                 \\frac{\\sin\\left(\\frac{m\\varphi}{4}\\right)}{b}&lt;br \/&gt;&lt;br \/&gt;&lt;br \/&gt;         \\right| ^{n_{3}}&lt;br \/&gt;&lt;br \/&gt;&lt;br \/&gt; \\right] ^{-\\frac{1}{n_{1}}}&lt;br \/&gt;&lt;br \/&gt;&lt;br \/&gt; \" src=\"http:\/\/upload.wikimedia.org\/math\/3\/7\/1\/37188eb6e21255282d47addba5118740.png\" \/><\/p>\n<p>\u5728\u6781\u5750\u6807\u7cfb\u4e0b\uff0cr\u4ee3\u8868\u534a\u5f84\uff0c<img decoding=\"async\" alt=\"\\varphi\" src=\"http:\/\/upload.wikimedia.org\/math\/3\/5\/3\/3538eb9c84efdcbd130c4c953781cfdb.png\" \/>\u4ee3\u8868\u89d2\u5ea6\uff0ca,b,m,n1,n2,n3\u662f\u53ef\u53d8\u53c2\u6570\u3002\u901a\u8fc7\u8c03\u6574\u53c2\u6570\u7684\u503c\uff0c\u5c31\u53ef\u4ee5\u7ed8\u51fa\u5404\u79cd\u56fe\u5f62\u3002\u4e0b\u56fe\u5c55\u793a\u4e86a=b=1\u7684\u60c5\u51b5\u4e0b\uff0cm,n1,n2,n3\u53d6\u4e0d\u540c\u503c\u7684\u65f6\u5019<a href=\"http:\/\/en.wikipedia.org\/wiki\/Superformula\">superfomula<\/a>\u6240\u5c55\u793a\u7684\u56fe\u5f62\uff1a<\/p>\n<p><a href=\"http:\/\/en.wikipedia.org\/wiki\/File:Superformula.gif\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"http:\/\/upload.wikimedia.org\/wikipedia\/commons\/1\/1c\/Superformula.gif\" width=\"240\" height=\"400\" \/><\/a><\/p>\n<p>\u53ea\u901a\u8fc7\u63a7\u5236\u8fd9\u4e9b\u53c2\u6570\uff0c\u5c31\u80fd\u5728\u6781\u5750\u6807\u7cfb\u4e0b\u7ed8\u5236\u5982\u6b64\u4e0d\u540c\u7684\u5404\u79cd2D\u56fe\u5f62\uff0c\u662f\u4e0d\u662f\u5f88\u795e\u5947\uff1f\u8fd9\u5c31\u662f\u6570\u5b66\u8fd9\u4e00\u81ea\u7136\u79d1\u5b66\u7684\u738b\u51a0\u5b66\u79d1\u7684\u9b45\u529b\u3002<\/p>\n<blockquote><p>\u5173\u4e8esuperfomula\u7684\u66f4\u591a\u4ecb\u7ecd\uff1a<\/p>\n<p><a href=\"http:\/\/en.wikipedia.org\/wiki\/Superformula\">superfomula<\/a>\u7684\u53d1\u8868\u8005<a href=\"http:\/\/www.pg.science.ru.nl\/en\/johangielis.html\">Johan Gielis<\/a>\u535a\u58eb\uff081962-\uff09\u539f\u672c\u7684\u7814\u7a76\u65b9\u5411\u662f\u56ed\u827a\u5de5\u7a0b\u548c\u751f\u7269\u5b66\u3002\u5728\u4ed6\u7684\u65e9\u671f\u7814\u7a76\u9636\u6bb5\u4ed6\u5c31\u611f\u5174\u8da3\u4e8e\u4f7f\u7528\u6570\u5b66\u6a21\u578b\u8868\u5f81\u751f\u7269\u751f\u957f\u6027\u72b6\u30021994\u5e74\u53d1\u8868\u7684\u8bba\u6587\u4e2d\u4ed6\u5c31\u5f00\u59cb\u5f00\u59cb\u4f7f\u7528\u66f2\u7ebf\u63cf\u8ff0\u81ea\u7136\u5f62\u72b6\uff0c\u57281997\u5e74\u7684\u8bba\u6587\u4e2d\u4ed6\u53d1\u73b0\u5e7f\u4e49\u7684\u66f2\u7ebf\u6a21\u578b\u9002\u7528\u4e8e\u4efb\u4f55\u5bf9\u79f0\u5f62\u72b6\u3002\u57282003\u5e74\u53d1\u8868\u4e8e\u7f8e\u56fd\u690d\u7269\u5b66\u6742\u5fd7\u4e0a\u7684\u8bba\u6587<a href=\"http:\/\/www.amjbot.org\/content\/90\/3\/333.abstract\">A generic geometric transformation that unifies a large range of natural and abstract shapes<\/a>\u4e2d\uff0c\u4ed6\u63d0\u51fa\u4e86<a href=\"http:\/\/en.wikipedia.org\/wiki\/Superformula\">superfomula<\/a>\u3002<a href=\"http:\/\/en.wikipedia.org\/wiki\/Superformula\">superfomula<\/a>\u662f\u8d85\u7ea7\u692d\u5706\u516c\u5f0f<a title=\"Superellipse\" href=\"http:\/\/en.wikipedia.org\/wiki\/Superellipse\">superellipse<\/a>\u7684\u6269\u5c55\uff0c\u4f46\u5177\u6709\u66f4\u5e7f\u6cdb\u7684\u5b9e\u7528\u6027\u3002\u6b64\u540e\u6570\u767e\u7bc7\u8bba\u6587\u90fd\u5f15\u7528\u4e86superfomula\uff0c\u5e76\u4e14\u4ee5superfomula\u4e3a\u6307\u5bfc\u7684\u8ba1\u7b97\u673a\u7ed8\u56fe\u7a0b\u5e8f\u4e5f\u968f\u4e4b\u51fa\u73b0\u30022004\u5e74johan Gielis\u535a\u58eb\u6536\u5230\u4e86InterTech\u6280\u672f\u521b\u65b0\u5353\u8d8a\u5956\uff0c\u8be5\u5956\u4e3b\u8981\u9881\u53d1\u7ed9\u5bf9\u5e73\u9762\u827a\u672f\u53ca\u76f8\u5173\u4ea7\u4e1a\u4ea7\u751f\u91cd\u5927\u5f71\u54cd\u7684\u6280\u672f\u53d1\u660e\u3002superfomula\u4ece\u751f\u7269\u6280\u672f\u7814\u7a76\u4e2d\u8bde\u751f\uff0c\u5728\u6570\u5b66\u9886\u57df\u4e2d\u5347\u534e\uff0c\u5e76\u6700\u7ec8\u5e94\u7528\u5230\u8ba1\u7b97\u673a\u3001\u5e73\u9762\u8bbe\u8ba1\u7b49\u9886\u57df\u3002\u53ef\u8c13\u662f\u8de8\u5b66\u79d1\u7814\u7a76\u5e94\u7528\u7684\u6700\u597d\u6848\u4f8b\u4e4b\u4e00\u3002<\/p>\n<p>superfomula\u4e5f\u53ef\u4ee5\u6269\u5c55\u52303\u7ef4\uff0c4\u7ef4\u751a\u81f3\u66f4\u591a\u7ef4\u5ea6\u3002\u4f8b\u59823\u7ef4\u60c5\u51b5\u4e0b\uff0c\u56fe\u5f62\u53ef\u4ee5\u901a\u8fc7\u4e24\u4e2asuperfomula r1, r2\u6765\u751f\u6210\u3002\u5176\u6781\u5750\u6807\u7cfb\u4e0e\u7b1b\u5361\u5c14\u5750\u6807\u7cfb\u4e4b\u95f4\u8f6c\u6362\u5173\u7cfb\u4e3a\uff1a<\/p>\n<dl>\n<dd><img decoding=\"async\" alt=\" x \\,=\\, r_1(\\theta)\\cos(\\theta)r_2(\\phi)\\cos(\\phi)\" src=\"http:\/\/upload.wikimedia.org\/math\/5\/3\/9\/539e3c318d5acac15af4f94703b0c7f8.png\" \/><\/dd>\n<dd><img decoding=\"async\" alt=\" y \\,=\\, r_1(\\theta)\\sin(\\theta)r_2(\\phi)\\cos(\\phi)\" src=\"http:\/\/upload.wikimedia.org\/math\/0\/7\/3\/0732fb12e74e5d75fd112be8e834f7f9.png\" \/><\/dd>\n<dd><img decoding=\"async\" alt=\" z \\,=\\, r_2(\\phi)\\sin(\\phi)\" src=\"http:\/\/upload.wikimedia.org\/math\/2\/8\/2\/28202a0e47b4e07ca3ac430d48fd528e.png\" \/><\/dd>\n<\/dl>\n<p>\u5176\u4e2d\uff0c<img decoding=\"async\" alt=\"\\phi\" src=\"http:\/\/upload.wikimedia.org\/math\/7\/f\/2\/7f20aa0b3691b496aec21cf356f63e04.png\" \/>\u00a0\u53d8\u91cf\u503c\u57df\u4e3a[\u00a0<i>-\u03c0\/2<\/i>\u00a0,\u00a0<i>\u03c0\/2]<\/i>\u00a0(<a title=\"Latitude\" href=\"http:\/\/en.wikipedia.org\/wiki\/Latitude\">latitude<\/a>\u7ef4\u5ea6)\uff0c\u00a0<i>\u03b8\u53d8\u91cf\u503c\u57df\u4e3a<\/i>\u00a0[\u00a0<i>-\u03c0,\u00a0<\/i><i>\u03c0]<\/i>\u00a0(<a title=\"Longitude\" href=\"http:\/\/en.wikipedia.org\/wiki\/Longitude\">longitude<\/a>\u7cbe\u5ea6).<\/p>\n<p>&nbsp;<\/p><\/blockquote>\n<h2>\u6848\u4f8b\u53ca\u4ee3\u7801\u5b9e\u73b0<\/h2>\n<p>\u5728github\u4e0a\uff0c\u5df2\u7ecf\u6709\u4eba\u7528D3\u5b9e\u73b0\u4e86\u57fa\u4e8esuperfomula\u7684\u56fe\u5f62\u7ed8\u5236\u7a0b\u5e8f\u3002\u5927\u5bb6\u8bf7\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"http:\/\/bl.ocks.org\/mbostock\/1021103\">http:\/\/bl.ocks.org\/mbostock\/1021103<\/a>. \u8be5\u7a0b\u5e8f\u7684\u5173\u952e\u662f\u57fa\u4e8eD3\u7684superfomula\u5f00\u6e90\u63d2\u4ef6\u3002\u672c\u7740\u5b66\u4e60\u7684\u76ee\u7684\uff0c\u8fd9\u91cc\u4fdd\u5b58\u4e86\u8be5\u63d2\u4ef6\u7684\u6e90\u7801\uff0c\u4f60\u53ef\u4ee5\u590d\u5236\u5b83\u7136\u540e\u4fdd\u5b58\u4e3ad3-superfomula.js\u6765\u4f7f\u7528\uff1a<\/p>\n<h1 id=\"firstHeading\"><\/h1>\n<pre class=\"lang:default decode:true\" title=\"d3.superformula.js\">(function() {\nvar _symbol = d3.svg.symbol(),\n_line = d3.svg.line();\n\nd3.superformula = function() {\nvar type = _symbol.type(),\nsize = _symbol.size(),\nsegments = size,\nparams = {};\n\nfunction superformula(d, i) {\nvar n, p = _superformulaTypes[type.call(this, d, i)];\nfor (n in params) p[n] = params[n].call(this, d, i);\nreturn _superformulaPath(p, segments.call(this, d, i), Math.sqrt(size.call(this, d, i)));\n}\n\nsuperformula.type = function(x) {\nif (!arguments.length) return type;\ntype = d3.functor(x);\nreturn superformula;\n};\n\nsuperformula.param = function(name, value) {\nif (arguments.length &lt; 2) return params[name];\nparams[name] = d3.functor(value);\nreturn superformula;\n};\n\n\/\/ size of superformula in square pixels\nsuperformula.size = function(x) {\nif (!arguments.length) return size;\nsize = d3.functor(x);\nreturn superformula;\n};\n\n\/\/ number of discrete line segments\nsuperformula.segments = function(x) {\nif (!arguments.length) return segments;\nsegments = d3.functor(x);\nreturn superformula;\n};\n\nreturn superformula;\n};\n\nfunction _superformulaPath(params, n, diameter) {\nvar i = -1,\ndt = 2 * Math.PI \/ n,\nt,\nr = 0,\nx,\ny,\npoints = [];\n\nwhile (++i &lt; n) {\nt = params.m * (i * dt - Math.PI) \/ 4;\nt = Math.pow(Math.abs(Math.pow(Math.abs(Math.cos(t) \/ params.a), params.n2)\n+ Math.pow(Math.abs(Math.sin(t) \/ params.b), params.n3)), -1 \/ params.n1);\nif (t &gt; r) r = t;\npoints.push(t);\n}\n\nr = diameter * Math.SQRT1_2 \/ r;\ni = -1; while (++i &lt; n) {\nx = (t = points[i] * r) * Math.cos(i * dt);\ny = t * Math.sin(i * dt);\npoints[i] = [Math.abs(x) &lt; 1e-6 ? 0 : x, Math.abs(y) &lt; 1e-6 ? 0 : y];\n}\n\nreturn _line(points) + \"Z\";\n}\n\nvar _superformulaTypes = {\nasterisk: {m: 12, n1: .3, n2: 0, n3: 10, a: 1, b: 1},\nbean: {m: 2, n1: 1, n2: 4, n3: 8, a: 1, b: 1},\nbutterfly: {m: 3, n1: 1, n2: 6, n3: 2, a: .6, b: 1},\ncircle: {m: 4, n1: 2, n2: 2, n3: 2, a: 1, b: 1},\nclover: {m: 6, n1: .3, n2: 0, n3: 10, a: 1, b: 1},\ncloverFour: {m: 8, n1: 10, n2: -1, n3: -8, a: 1, b: 1},\ncross: {m: 8, n1: 1.3, n2: .01, n3: 8, a: 1, b: 1},\ndiamond: {m: 4, n1: 1, n2: 1, n3: 1, a: 1, b: 1},\ndrop: {m: 1, n1: .5, n2: .5, n3: .5, a: 1, b: 1},\nellipse: {m: 4, n1: 2, n2: 2, n3: 2, a: 9, b: 6},\ngear: {m: 19, n1: 100, n2: 50, n3: 50, a: 1, b: 1},\nheart: {m: 1, n1: .8, n2: 1, n3: -8, a: 1, b: .18},\nheptagon: {m: 7, n1: 1000, n2: 400, n3: 400, a: 1, b: 1},\nhexagon: {m: 6, n1: 1000, n2: 400, n3: 400, a: 1, b: 1},\nmalteseCross: {m: 8, n1: .9, n2: .1, n3: 100, a: 1, b: 1},\npentagon: {m: 5, n1: 1000, n2: 600, n3: 600, a: 1, b: 1},\nrectangle: {m: 4, n1: 100, n2: 100, n3: 100, a: 2, b: 1},\nroundedStar: {m: 5, n1: 2, n2: 7, n3: 7, a: 1, b: 1},\nsquare: {m: 4, n1: 100, n2: 100, n3: 100, a: 1, b: 1},\nstar: {m: 5, n1: 30, n2: 100, n3: 100, a: 1, b: 1},\ntriangle: {m: 3, n1: 100, n2: 200, n3: 200, a: 1, b: 1}\n};\n\nd3.superformulaTypes = d3.keys(_superformulaTypes);\n})();<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9700\u6c42\u9a71\u52a8\u5b9e\u73b0 \u524d\u6587\u8bb2\u8fc7\u4e86D3\u7684\u6570\u636e\u9a71\u52a8\u673a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[27,28,110,163],"class_list":["post-1020","post","type-post","status-publish","format-standard","hentry","category-data-visualization","tag-d3js","tag-d3","tag-110","tag-163"],"_links":{"self":[{"href":"https:\/\/www.divis.cn\/index.php\/wp-json\/wp\/v2\/posts\/1020","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.divis.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.divis.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.divis.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.divis.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1020"}],"version-history":[{"count":0,"href":"https:\/\/www.divis.cn\/index.php\/wp-json\/wp\/v2\/posts\/1020\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.divis.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.divis.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.divis.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}