Volume Cartographer 2.27.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
MeshMath.hpp
Go to the documentation of this file.
1#pragma once
2
14
15namespace volcart::meshmath
16{
17
23template <
24 typename T,
25 std::enable_if_t<std::is_floating_point<T>::value, bool> = true>
26T TriangleArea(T a, T b, T c)
27{
28 // Sort the side lengths so that a >= b >= c
29 auto nc = std::min(a, std::min(b, c));
30 auto na = std::max(a, std::max(b, c));
31 auto nb = a + b + c - na - nc;
32
33 // Calculate the area
34 auto p = (na + (nb + nc)) * (nc - (na - nb)) * (nc + (na - nb)) *
35 (na + (nb - nc));
36
37 return 0.25 * std::sqrt(p);
38}
39
41double SurfaceArea(const ITKMesh::Pointer& mesh);
42
43} // namespace volcart::meshmath
Mesh mathematical operations.
T TriangleArea(T a, T b, T c)
Calculate the area of a triangle given its side lengths.
Definition: MeshMath.hpp:26
double SurfaceArea(const ITKMesh::Pointer &mesh)
Calculate the surface area of an ITKMesh.