17void verify(
const Eigen::Vector3d ¢er,
const Eigen::Matrix3d &axes)
20 check(
mesh->GetNumberOfPoints() > 0 &&
mesh->GetNumberOfCells() > 0,
"Empty ellipsoid geometry");
21 const Eigen::Matrix3d inverse = axes.inverse();
22 auto *normals =
mesh->GetPointData()->GetNormals();
23 check(normals !=
nullptr,
"Missing surface normals");
24 Eigen::Matrix<double, 3, 2> tipDistance =
25 Eigen::Matrix<double, 3, 2>::Constant(std::numeric_limits<double>::infinity());
26 for(vtkIdType
k = 0;
k <
mesh->GetNumberOfPoints(); ++
k)
30 normals->GetTuple(
k, n);
31 const Eigen::Vector3d position(
p[0],
p[1],
p[2]);
32 const Eigen::Vector3d unit = inverse * (position - center);
33 check(std::abs(unit.squaredNorm() - 1.0) < 1.e-11,
"Incorrect surface scale or orientation");
34 const Eigen::Vector3d normal(n[0], n[1], n[2]);
35 const Eigen::Vector3d expectedNormal = (inverse.transpose() * unit).normalized();
36 check(normal.normalized().dot(expectedNormal) > 1.0 - 1.e-6,
"Incorrect transformed surface normal");
37 for(
int j = 0;
j < 3; ++
j)
39 tipDistance(
j, 0) = std::min(tipDistance(
j, 0), (position - center - axes.col(
j)).norm());
40 tipDistance(
j, 1) = std::min(tipDistance(
j, 1), (position - center + axes.col(
j)).norm());
43 check(tipDistance.maxCoeff() < 1.e-10,
"Semiaxis endpoints missing or misoriented");
50 const Eigen::Vector3d center(4, -3, 2);
51 verify(center, Eigen::Vector3d(3, 2, 1).asDiagonal());
52 const Eigen::Matrix3d rotation =
53 Eigen::AngleAxisd(.73, Eigen::Vector3d(1, 2, 3).normalized()).toRotationMatrix();
54 Eigen::Matrix3d axes = rotation * Eigen::Vector3d(7, 2, .5).asDiagonal();
58 axes.col(0).swap(axes.col(2));
60 verify(center, 2.0 * Eigen::Matrix3d::Identity());
62 <<
"PASS rendered ellipsoid surfaces, semiaxis endpoints, rotation, reflection, permutation and normals\n";
65 catch(
const std::exception &error)
67 std::cerr << error.what() <<
'\n';