39 Eigen::PlainObjectBase<DerivedY> &
Y,
40 Eigen::PlainObjectBase<DerivedIX> &IX)
42 using namespace Eigen;
44 typedef typename Eigen::PlainObjectBase<DerivedY>::Scalar YScalar;
47 int num_outer = (dim == 1 ?
X.cols() :
X.rows());
49 int num_inner = (dim == 1 ?
X.rows() :
X.cols());
50 assert(num_inner == 3);
52 typedef typename Eigen::PlainObjectBase<DerivedIX>::Scalar Index;
53 IX.resize(
X.rows(),
X.cols());
55 IX.row(0).setConstant(0);
56 IX.row(1).setConstant(1);
57 IX.row(2).setConstant(2);
60 IX.col(0).setConstant(0);
61 IX.col(1).setConstant(1);
62 IX.col(2).setConstant(2);
66 threading::parallel_for(
68 for (
const Index i :
range) {
69 YScalar &a = (dim == 1 ?
Y(0, i) :
Y(i, 0));
70 YScalar &
b = (dim == 1 ?
Y(1, i) :
Y(i, 1));
71 YScalar &c = (dim == 1 ?
Y(2, i) :
Y(i, 2));
72 Index &ai = (dim == 1 ? IX(0, i) : IX(i, 0));
73 Index &bi = (dim == 1 ? IX(1, i) : IX(i, 1));
74 Index &ci = (dim == 1 ? IX(2, i) : IX(i, 2));
117 const Eigen::PlainObjectBase<DerivedF> &F,
118 Eigen::PlainObjectBase<DeriveddblA> &dblA)
120 const int dim =
V.cols();
122 assert(F.cols() == 3);
123 const size_t m = F.rows();
125 Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 3>
l;
128 const auto &proj_doublearea = [&
V, &
F](
const int x,
const int y,
const int f) ->
double {
129 auto rx =
V(
F(f, 0), x) -
V(
F(f, 2), x);
130 auto sx =
V(
F(f, 1), x) -
V(
F(f, 2), x);
131 auto ry =
V(
F(f, 0), y) -
V(
F(f, 2), y);
132 auto sy =
V(
F(f, 1), y) -
V(
F(f, 2), y);
133 return rx * sy - ry * sx;
138 dblA = Eigen::PlainObjectBase<DeriveddblA>::Zero(m, 1);
139 for (
size_t f = 0; f < m; f++) {
140 for (
int d = 0; d < 3; d++) {
141 double dblAd = proj_doublearea(d, (d + 1) % 3, f);
142 dblA(f) += dblAd * dblAd;
145 dblA = dblA.array().sqrt().eval();
150 for (
size_t f = 0; f < m; f++) {
151 dblA(f) = proj_doublearea(0, 1, f);
163inline void doublearea(
const Eigen::PlainObjectBase<Derivedl> &ul,
164 Eigen::PlainObjectBase<DeriveddblA> &dblA)
166 using namespace Eigen;
168 typedef typename Derivedl::Index Index;
170 assert(ul.cols() == 3);
172 const Index m = ul.rows();
173 Eigen::Matrix<typename Derivedl::Scalar, Eigen::Dynamic, 3>
l;
182 dblA.resize(
l.rows(), 1);
186 for (
const Index i :
range) {
188 const typename Derivedl::Scalar arg = (
l(i, 0) + (
l(i, 1) +
l(i, 2))) *
189 (
l(i, 2) - (
l(i, 0) -
l(i, 1))) *
190 (
l(i, 2) + (
l(i, 0) -
l(i, 1))) *
191 (
l(i, 0) + (
l(i, 1) -
l(i, 2)));
192 dblA(i) = 2.0 * 0.25 *
sqrt(arg);
193 assert(
l(i, 2) - (
l(i, 0) -
l(i, 1)) &&
"FAILED KAHAN'S ASSERTION");
194 assert(dblA(i) == dblA(i) &&
"DOUBLEAREA() PRODUCED NaN");
static void doublearea_sort3(const Eigen::PlainObjectBase< DerivedX > &X, const int dim, const bool ascending, Eigen::PlainObjectBase< DerivedY > &Y, Eigen::PlainObjectBase< DerivedIX > &IX)