69 std::array<double, 3>
cross(
const std::array<double, 3> &A,
const std::array<double, 3> &B) {
70 std::array<double, 3> product;
72 product[0] = (A[1] * B[2]) - (A[2] * B[1]);
73 product[1] = -((A[0] * B[2]) - (A[2] * B[0]));
74 product[2] = (A[0] * B[1]) - (A[1] * B[0]);
96 std::array<double, 3> t_vec = math::vector_cross::cross({1, 2, 3}, {4, 5, 6});
97 assert(t_vec[0] == -3 && t_vec[1] == 6 && t_vec[2] == -3);
100 double t_mag = math::vector_cross::mag({6, 8, 0});
114 std::array<double, 3> vec1;
115 std::array<double, 3> vec2;
118 std::cout <<
"\nPass the first Vector: ";
119 std::cin >> vec1[0] >> vec1[1] >> vec1[2];
122 std::cout <<
"\nPass the second Vector: ";
123 std::cin >> vec2[0] >> vec2[1] >> vec2[2];
126 std::array<double, 3> product = math::vector_cross::cross(vec1, vec2);
127 std::cout <<
"\nThe cross product is: " << product[0] <<
" " << product[1] <<
" " << product[2] << std::endl;
130 std::cout <<
"Magnitude: " << math::vector_cross::mag(product) <<
"\n" << std::endl;
std::array< double, 3 > cross(const std::array< double, 3 > &A, const std::array< double, 3 > &B)
Function to calculate the cross product of the passed arrays containing the direction ratios of the t...