19#ifndef UTILS_MATH_TRIANGLE_FUNCTIONS_HPP
20#define UTILS_MATH_TRIANGLE_FUNCTIONS_HPP
39 auto const u = P2 - P1;
40 auto const v = P3 - P1;
83 auto const denominator = std::sqrt(normal1.norm2() * normal2.norm2());
84 auto const cosine = std::clamp(normal1 * normal2 / denominator, -1., 1.);
88 auto const phi = std::numbers::pi - std::acos(cosine);
99 if (normal1 * P4 - normal1 * P1 < 0)
100 return 2. * std::numbers::pi - phi;
Vector implementation and trait types for boost qvm interoperability.
double angle_btw_triangles(const Vector3d &P1, const Vector3d &P2, const Vector3d &P3, const Vector3d &P4)
Computes the angle between two triangles in 3D space.
Vector< T, 3 > vector_product(Vector< T, 3 > const &a, Vector< T, 3 > const &b)
double area_triangle(const Vector3d &P1, const Vector3d &P2, const Vector3d &P3)
Computes the area of triangle between vectors P1,P2,P3, by computing the cross product P1P2 x P1P3 an...
Vector3d get_n_triangle(const Vector3d &P1, const Vector3d &P2, const Vector3d &P3)
Computes the normal vector of a triangle.