15 #ifndef CORE_UTIL_MATH_H_
16 #define CORE_UTIL_MATH_H_
43 dist_array[0] = pos2[0] - pos1[0];
44 dist_array[1] = pos2[1] - pos1[1];
45 dist_array[2] = pos2[2] - pos1[2];
46 return dist_array.
Norm();
53 template <std::
size_t N>
57 result[0] = a[1] * b[2] - a[2] * b[1];
58 result[1] = a[2] * b[0] - a[0] * b[2];
59 result[2] = a[0] * b[1] - a[1] * b[0];
97 auto temp_1 = naxis * (vector * naxis);
98 auto temp_2 = (vector - temp_1) * std::cos(-theta);
99 auto temp_3 =
CrossProduct(vector, naxis) * std::sin(-theta);
101 return temp_1 + temp_2 + temp_3;
109 return std::acos(a * b / (a.
Norm() * b.
Norm()));
117 real_t k = (a * b) / (b * b);
123 const std::vector<real_t>& v2) {
124 if (v1.size() != v2.size()) {
125 Log::Fatal(
"Math::MSE",
"vectors must have same length");
128 for (
size_t i = 0; i < v1.size(); ++i) {
129 auto diff = v2[i] - v1[i];
130 error += diff * diff;
132 return error / v1.size();
138 #endif // CORE_UTIL_MATH_H_