1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-20 05:21:38 +02:00

add spherical_coordinate

This commit is contained in:
Justin Lin
2021-02-13 11:00:09 +08:00
parent 52dad85109
commit ca19568ae2
3 changed files with 30 additions and 1 deletions

View File

@@ -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)

View File

@@ -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 <util/spherical_coordinate.scad>;
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]);

View File

@@ -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]
[