OpenSCAD Spherical Translate
22nd September 2013
In many OpenSCAD designs I have needed to work out some trigonometry and convert this into a series of translate() and rotate() functions for each component of the design. This is somewhat tedious and makes for some rather unreadable code.
In computer game programming spherical coordinates are particularly popular as they make lots of the calculations easier to understand. Since I started using spherical coordinates in OpenSCAD they have become my de-facto solution for a lot of cases.
Use the spherical_translate() as you would translate() but instead of passing an array of [x, y, z] pass an array of [radius, inclination, azimuth].
Here is the spherical_translate() module and an example: