MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / cart_to_sph_position

Function cart_to_sph_position

examples/pde/bhrt.cpp:187–202  ·  view source on GitHub ↗

* @brief Transform the position vectors from cartesian to spherical coordinates * * @param pos * @return af::array */

Source from the content-addressed store, hash-verified

185 * @return af::array
186 */
187af::array cart_to_sph_position(const af::array& pos) {
188 if (pos.dims()[0] != 3)
189 throw make_error("Arrays must have 3 principal coordintes");
190
191 af::array x = pos(0, af::span);
192 af::array y = pos(1, af::span);
193 af::array z = pos(2, af::span);
194
195 af::array r = af::sqrt(x * x + y * y + z * z);
196 af::array o = af::acos(z / r);
197 af::array p = af::atan2(y, x);
198
199 af::array transformed_pos = af::join(0, r, o, p);
200
201 return transformed_pos;
202}
203
204/**
205 * @brief Transform the velocity vectors from cartesian to spherical coordinates

Callers 2

get_colorMethod · 0.85

Calls 6

make_errorFunction · 0.85
sqrtFunction · 0.85
acosFunction · 0.85
atan2Function · 0.85
joinFunction · 0.50
dimsMethod · 0.45

Tested by

no test coverage detected