* @brief Computes the cross_product of two euclidean vectors * * @param lhs * @param rhs * @return af::array */
| 163 | * @return af::array |
| 164 | */ |
| 165 | af::array cross_product(const af::array& lhs, const af::array& rhs) { |
| 166 | if (lhs.dims() != rhs.dims()) |
| 167 | throw make_error("Arrays must have the same dimensions"); |
| 168 | else if (lhs.dims()[0] != 3) |
| 169 | throw make_error("Arrays must have 3 principal coordintes"); |
| 170 | |
| 171 | return af::join( |
| 172 | 0, |
| 173 | lhs(1, af::span, af::span) * rhs(2, af::span, af::span) - |
| 174 | lhs(2, af::span, af::span) * rhs(1, af::span, af::span), |
| 175 | lhs(2, af::span, af::span) * rhs(0, af::span, af::span) - |
| 176 | lhs(0, af::span, af::span) * rhs(2, af::span, af::span), |
| 177 | lhs(0, af::span, af::span) * rhs(1, af::span, af::span) - |
| 178 | lhs(1, af::span, af::span) * rhs(0, af::span, af::span)); |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * @brief Transform the position vectors from cartesian to spherical coordinates |
no test coverage detected