mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 01:05:58 +08:00
Measuring - Gizmo measure - Fixed measure of distance point-circle when the point is the circle's center
This commit is contained in:
parent
121b0f9a60
commit
ca923c084f
@ -632,13 +632,21 @@ MeasurementResult get_measurement(const SurfaceFeature& a, const SurfaceFeature&
|
|||||||
} else if (f2.get_type() == SurfaceFeatureType::Circle) {
|
} else if (f2.get_type() == SurfaceFeatureType::Circle) {
|
||||||
// Find a plane containing normal, center and the point.
|
// Find a plane containing normal, center and the point.
|
||||||
const auto [c, radius, n] = f2.get_circle();
|
const auto [c, radius, n] = f2.get_circle();
|
||||||
Eigen::Hyperplane<double, 3> circle_plane(n, c);
|
const Eigen::Hyperplane<double, 3> circle_plane(n, c);
|
||||||
Vec3d proj = circle_plane.projection(f1.get_point());
|
const Vec3d proj = circle_plane.projection(f1.get_point());
|
||||||
double dist = std::sqrt(std::pow((proj - c).norm() - radius, 2.) +
|
if (proj.isApprox(c)) {
|
||||||
(f1.get_point() - proj).squaredNorm());
|
const Vec3d p_on_circle = c + radius * get_orthogonal(n, true);
|
||||||
|
result.distance_strict = std::make_optional(DistAndPoints{ radius, c, p_on_circle });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const Eigen::Hyperplane<double, 3> circle_plane(n, c);
|
||||||
|
const Vec3d proj = circle_plane.projection(f1.get_point());
|
||||||
|
const double dist = std::sqrt(std::pow((proj - c).norm() - radius, 2.) +
|
||||||
|
(f1.get_point() - proj).squaredNorm());
|
||||||
|
|
||||||
const Vec3d p_on_circle = c + radius * (circle_plane.projection(f1.get_point()) - c).normalized();
|
const Vec3d p_on_circle = c + radius * (proj - c).normalized();
|
||||||
result.distance_strict = std::make_optional(DistAndPoints{dist, f1.get_point(), p_on_circle}); // TODO
|
result.distance_strict = std::make_optional(DistAndPoints{ dist, f1.get_point(), p_on_circle }); // TODO
|
||||||
|
}
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
} else if (f2.get_type() == SurfaceFeatureType::Plane) {
|
} else if (f2.get_type() == SurfaceFeatureType::Plane) {
|
||||||
const auto [idx, normal, pt] = f2.get_plane();
|
const auto [idx, normal, pt] = f2.get_plane();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user