Skip to content

Instantly share code, notes, and snippets.

@greenarrow
Last active December 23, 2015 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenarrow/6659448 to your computer and use it in GitHub Desktop.
Save greenarrow/6659448 to your computer and use it in GitHub Desktop.
OpenSCAD Spherical Translate
/* http://en.wikipedia.org/wiki/Spherical_coordinate_system */
module spherical_translate(value)
{
radius = value[0];
inclination = value[1];
azimuth = value[2];
x = radius * sin(inclination) * cos(azimuth);
y = radius * sin(inclination) * sin(azimuth);
z = radius * cos(inclination);
for (i = [0 : $children - 1]) {
translate([x, y, z])
child(i);
}
}
for (b = [0 : 90 : 360]) {
for (a = [0: 30: 360]) {
spherical_translate([50, a, b])
cube(10, center = true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment