Created
January 13, 2013 19:52
-
-
Save will-in-wi/4525887 to your computer and use it in GitHub Desktop.
Basic code to create a filled sphere with ScriptCraft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sphere(material, radius) { | |
for (var i = 0; i <= radius; i++) { | |
up(radius + i).fwd(radius - Math.round(Math.sqrt(radius*radius - i*i))).right(radius - Math.round(Math.sqrt(radius*radius - i*i))).cylinder(material, Math.round(Math.sqrt(radius*radius - i*i)), 1); | |
up(radius - i).fwd(radius - Math.round(Math.sqrt(radius*radius - i*i))).right(radius - Math.round(Math.sqrt(radius*radius - i*i))).cylinder(material, Math.round(Math.sqrt(radius*radius - i*i)), 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment