diff --git a/README.md b/README.md index a2dec932..0dfe2013 100644 --- a/README.md +++ b/README.md @@ -151,7 +151,7 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp - [util/slice](https://openhome.cc/eGossip/OpenSCAD/lib3x-slice.html) - [util/some](https://openhome.cc/eGossip/OpenSCAD/lib3x-some.html) - [util/sort](https://openhome.cc/eGossip/OpenSCAD/lib3x-sort.html) -- util/spherical_coordinate +- [util/spherical_coordinate](https://openhome.cc/eGossip/OpenSCAD/lib3x-spherical_coordinate.html) - [util/sub_str](https://openhome.cc/eGossip/OpenSCAD/lib3x-sub_str.html) - [util/split_str](https://openhome.cc/eGossip/OpenSCAD/lib3x-split_str.html) - [util/sum](https://openhome.cc/eGossip/OpenSCAD/lib3x-sum.html) diff --git a/docs/lib3x-spherical_coordinate.md b/docs/lib3x-spherical_coordinate.md new file mode 100644 index 00000000..c4dd4c36 --- /dev/null +++ b/docs/lib3x-spherical_coordinate.md @@ -0,0 +1,19 @@ +# spherical_coordinate + +Converts from Cartesian to Polar coordinates. It returns `[radius, theta, phi]`. + +**Since:** 3.0 + +## Parameters + +- `point` : The Cartesian coordinates of a point. + +## Examples + + use ; + + coord = spherical_coordinate([100, 100, 100]); + r = round(coord[0]); + theta = round(coord[1]); + phi = round(coord[2]); + assert([r, theta, phi] == [173, 45, 35]); \ No newline at end of file diff --git a/src/util/spherical_coordinate.scad b/src/util/spherical_coordinate.scad index 47608097..a65e9e99 100644 --- a/src/util/spherical_coordinate.scad +++ b/src/util/spherical_coordinate.scad @@ -1,3 +1,13 @@ +/** +* spherical_coordinate.scad +* +* @copyright Justin Lin, 2020 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-spherical_coordinate.html +* +**/ + function spherical_coordinate(point) = // mathematics [r, theta, phi] [