Wildmeshing Toolkit
Loading...
Searching...
No Matches
triangle_areas.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Dense>
4
5
6namespace wmtk::utils {
7
8// template get 3d tri area
9template <typename ADerived, typename BDerived, typename CDerived>
11 const Eigen::MatrixBase<ADerived>& a,
12 const Eigen::MatrixBase<BDerived>& b,
13 const Eigen::MatrixBase<CDerived>& c) -> typename ADerived::Scalar
14{
15 auto ba = b - a;
16 auto ca = c - a;
17 return typename ADerived::Scalar(.5) * ba.cross(ca).norm();
18}
19
20// template get 3d tri area
21template <typename ADerived, typename BDerived, typename CDerived>
23 const Eigen::MatrixBase<ADerived>& a,
24 const Eigen::MatrixBase<BDerived>& b,
25 const Eigen::MatrixBase<CDerived>& c) -> typename ADerived::Scalar
26{
27 auto ba = (b - a).eval();
28 auto ca = (c - a).eval();
29 return typename ADerived::Scalar(.5) * ba.homogeneous().cross(ca.homogeneous()).z();
30}
31
32template <typename ADerived, typename BDerived, typename CDerived>
34 const Eigen::MatrixBase<ADerived>& a,
35 const Eigen::MatrixBase<BDerived>& b,
36 const Eigen::MatrixBase<CDerived>& c) -> typename ADerived::Scalar
37{
38 return std::abs(triangle_signed_2d(a, b, c));
39}
40
41// private:
42// class Internal
43// {
44// private:
45// Internal();
46
47// public:
48// Internal& instance();
49// double orient2d_aux(double pa[2], double pb[2], double pc[2]);
50// double orient3d_aux(double pa[3], double pb[3], double pc[3], double pd[3]);
51// double incircle_aux(double pa[2], double pb[2], double pc[2], double pd[2]);
52// double insphere_aux(double pa[3], double pb[3], double pc[3], double pd[3], double
53// pe[3]);
54// };
55// };
56} // namespace wmtk::utils
auto triangle_unsigned_2d_area(const Eigen::MatrixBase< ADerived > &a, const Eigen::MatrixBase< BDerived > &b, const Eigen::MatrixBase< CDerived > &c) -> typename ADerived::Scalar
auto triangle_3d_area(const Eigen::MatrixBase< ADerived > &a, const Eigen::MatrixBase< BDerived > &b, const Eigen::MatrixBase< CDerived > &c) -> typename ADerived::Scalar
auto triangle_signed_2d_area(const Eigen::MatrixBase< ADerived > &a, const Eigen::MatrixBase< BDerived > &b, const Eigen::MatrixBase< CDerived > &c) -> typename ADerived::Scalar