* @brief Transform the velocity vectors from oblate to cartesian coordinates * * @param vel * @param pos * @return af::array */
| 328 | * @return af::array |
| 329 | */ |
| 330 | af::array oblate_to_cart_velocity(const af::array& vel, const af::array& pos) { |
| 331 | if (vel.dims() != pos.dims()) |
| 332 | throw make_error("Arrays must have the same dimensions"); |
| 333 | else if (pos.dims()[0] != 3) |
| 334 | throw make_error("Arrays must have 3 principal coordintes"); |
| 335 | |
| 336 | af::array r = pos(0, af::span); |
| 337 | af::array o = pos(1, af::span); |
| 338 | af::array p = pos(2, af::span); |
| 339 | |
| 340 | af::array ur = vel(0, af::span); |
| 341 | af::array uo = vel(1, af::span); |
| 342 | af::array up = vel(2, af::span); |
| 343 | |
| 344 | double a = J / M; |
| 345 | af::array ra = af::sqrt(r * r + a * a); |
| 346 | |
| 347 | af::array ux = |
| 348 | (ur * r * af::sin(o) / ra + uo * ra * af::cos(o)) * af::cos(p) - |
| 349 | up * r * af::sin(o) * af::sin(p); |
| 350 | af::array uy = |
| 351 | (ur * r * af::sin(o) / ra + uo * ra * af::cos(o)) * af::sin(p) + |
| 352 | up * r * af::sin(o) * af::cos(p); |
| 353 | af::array uz = ur * af::cos(o) - uo * r * af::sin(o); |
| 354 | af::array transformed_vel = af::join(0, ux, uy, uz); |
| 355 | |
| 356 | return transformed_vel; |
| 357 | } |
| 358 | |
| 359 | /** |
| 360 | * @brief Transform the velocity vectors from cartesian to oblate coordinates |
no test coverage detected