diff --git a/README.md b/README.md index 15189c42..a2dec932 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ These examples incubate dotSCAD and dotSCAD refactors these examples. See [examp - [util/has](https://openhome.cc/eGossip/OpenSCAD/lib3x-has.html) - [util/lerp](https://openhome.cc/eGossip/OpenSCAD/lib3x-lerp.html) - [util/parse_number](https://openhome.cc/eGossip/OpenSCAD/lib3x-parse_number.html) -- util/polar_coordinate +- [util/polar_coordinate](https://openhome.cc/eGossip/OpenSCAD/lib3x-polar_coordinate.html) - [util/radians](https://openhome.cc/eGossip/OpenSCAD/lib3x-radians.html) - [util/rand](https://openhome.cc/eGossip/OpenSCAD/lib3x-rand.html) - [util/reverse](https://openhome.cc/eGossip/OpenSCAD/lib3x-reverse.html) diff --git a/docs/lib3x-polar_coordinate.md b/docs/lib3x-polar_coordinate.md new file mode 100644 index 00000000..5cffcd87 --- /dev/null +++ b/docs/lib3x-polar_coordinate.md @@ -0,0 +1,18 @@ +# polar_coordinate + +Converts from Cartesian to Polar coordinates. + +**Since:** 3.0 + +## Parameters + +- `point` : The Cartesian coordinates (also called rectangular coordinates) of a point. + +## Examples + + use ; + + coord = polar_coordinate([100, 100]); + r = round(coord[0]); + theta = round(coord[1]); + assert([r, theta] == [141, 45]); \ No newline at end of file diff --git a/src/util/polar_coordinate.scad b/src/util/polar_coordinate.scad index 56ea5335..0c6ca55d 100644 --- a/src/util/polar_coordinate.scad +++ b/src/util/polar_coordinate.scad @@ -1,3 +1,13 @@ +/** +* polar_coordinate.scad +* +* @copyright Justin Lin, 2020 +* @license https://opensource.org/licenses/lgpl-3.0.html +* +* @see https://openhome.cc/eGossip/OpenSCAD/lib3x-polar_coordinate.html +* +**/ + use <../__comm__/__angy_angz.scad>; function polar_coordinate(point) = [norm(point), atan2(point[1], point[0])]; // r, theta \ No newline at end of file