{"id":403,"date":"2009-09-12T08:38:15","date_gmt":"2009-09-12T15:38:15","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2154"},"modified":"2009-09-12T08:38:15","modified_gmt":"2009-09-12T15:38:15","slug":"calculate-surface-area-and-volume-of-a-sphere","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=403","title":{"rendered":"Calculate Surface Area and Volume of a Sphere"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n \r\nvar rad:Number = 1;\r\n\r\nvar surfaceArea:Number = sphereSurfaceArea(rad);\r\nvar volume:Number = sphereVolume(rad)\r\ntrace(&quot;surface area: &quot;, surfaceArea);\r\ntrace(&quot;volume:&quot;, volume);\r\ntrace(&quot;volume \/ surface area:&quot;, volume \/ surfaceArea);\r\n\r\nfunction sphereSurfaceArea(r:Number):Number{\r\n\treturn 4 * Math.PI * r * r;\r\n}\r\n\r\nfunction sphereVolume(r:Number):Number{\r\n\treturn r * r * r * (4.0\/3.0) * Math.PI;\r\n}\r\n\r\n\/*outputs:\r\nsurface area:  12.566370614359172\r\nvolume: 4.1887902047863905\r\nvolume \/ surface area: 0.3333333333333333\r\n*\/\r\n<\/pre>\n<p>Last night I was feeling curious about sphere volume and sphere surface area&#8230; I used <a href=\"http:\/\/www.wolframalpha.com\/\" target=\"blank\">WolframAlpha<\/a> to find the neccessary equations and then wrote the above code snippet&#8230;<\/p>\n<p>Check out how WolframAlpha does it:<br \/>\n<a href=\"http:\/\/www.wolframalpha.com\/input\/?i=surface+area+of+a+sphere\" target=\"blank\">surface area of a sphere<\/a><br \/>\n<a href=\"http:\/\/www.wolframalpha.com\/input\/?i=surface+area+of+a+sphere+with+radius+10\" target=\"blank\">surface area of a sphere with radius 10<\/a><br \/>\n<a href=\"http:\/\/www.wolframalpha.com\/input\/?i=sphere+volume\" target=\"blank\">sphere volume<\/a><br \/>\n<a href=\"http:\/\/www.wolframalpha.com\/input\/?i=sphere+volume+with+radius+10\" target=\"blank\">sphere volume with radius 10<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>var rad:Number = 1; var surfaceArea:Number = sphereSurfaceArea(rad); var volume:Number = sphereVolume(rad) trace(&quot;surface area: &quot;, surfaceArea); trace(&quot;volume:&quot;, volume); trace(&quot;volume \/ surface area:&quot;, volume \/ surfaceArea); function sphereSurfaceArea(r:Number):Number{ return 4 * Math.PI * r * r; } function sphereVolume(r:Number):Number{ return r * r * r * (4.0\/3.0) * Math.PI; } \/*outputs: surface area: 12.566370614359172 volume: 4.1887902047863905 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121,94],"tags":[3,14,4,130],"class_list":["post-403","post","type-post","status-publish","format-standard","hentry","category-math","category-misc","tag-actionscript","tag-as3","tag-flash","tag-wolframalpha"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/403","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=403"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/403\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}