50 auto const& vp = p.asEigenVector3d();
53 Eigen::Vector3d
const axb = a.cross(b);
55 if (axb.squaredNorm() > 0)
57 double const denom = 2.0 * axb.dot(axb);
59 (b.dot(b) * axb.cross(a) + a.dot(a) * b.cross(axb)) / denom;
60 _radius = o.norm() + std::numeric_limits<double>::epsilon();
67 if (a.squaredNorm() > b.squaredNorm())
91 double const denom = 2.0 * va.cross(vb).dot(vc);
93 (vc.dot(vc) * va.cross(vb) + vb.dot(vb) * vc.cross(va) +
94 va.dot(va) * vb.cross(vc)) /
97 _radius = o.norm() + std::numeric_limits<double>::epsilon();
98 o += p.asEigenVector3d();
127MinimalBoundingSphere::MinimalBoundingSphere(
128 std::vector<MathLib::Point3d*>
const& points)
129 : _radius(-1), _center({0, 0, 0})
131 const std::vector<MathLib::Point3d*>& sphere_points(points);
133 recurseCalculation(sphere_points, 0, sphere_points.size(), 0);
139 std::vector<MathLib::Point3d*> sphere_points,
140 std::size_t start_idx,
142 std::size_t n_boundary_points)
145 switch (n_boundary_points)
155 *sphere_points[start_idx - 2]);
159 *sphere_points[start_idx - 2],
160 *sphere_points[start_idx - 3]);
164 *sphere_points[start_idx - 1], *sphere_points[start_idx - 2],
165 *sphere_points[start_idx - 3], *sphere_points[start_idx - 4]);
169 for (std::size_t i = 0; i < length; ++i)
177 std::vector<MathLib::Point3d*>::iterator::difference_type;
178 std::vector<MathLib::Point3d*>
const tmp_ps(
179 sphere_points.cbegin() +
static_cast<DiffType
>(start_idx),
180 sphere_points.cbegin() +
181 static_cast<DiffType
>(start_idx + i + 1));
182 std::copy(tmp_ps.cbegin(), --tmp_ps.cend(),
183 sphere_points.begin() +
184 static_cast<DiffType
>(start_idx + 1));
185 sphere_points[start_idx] = tmp_ps.back();
188 n_boundary_points + 1);
bool isCoplanar(const MathLib::Point3d &a, const MathLib::Point3d &b, const MathLib::Point3d &c, const MathLib::Point3d &d)
Checks if the four given points are located on a plane.