Tech ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS - Reworked detection of collision with printbed. The detection uses now different algorithms in dependence of the printbed type (rectangular, circular, convex) to improve performance.

This commit is contained in:
enricoturri1966
2021-10-06 13:47:54 +02:00
parent a7ea88befb
commit d03fd2f63e
10 changed files with 209 additions and 74 deletions

View File

@@ -282,9 +282,11 @@ bool Bed3D::is_circle(const Pointfs& shape, Vec2d* center, double* radius)
avg_dist /= vertex_distances.size();
double tolerance = avg_dist * 0.01;
bool defined_value = true;
for (double el : vertex_distances) {
if (fabs(el - avg_dist) > 10.0 * SCALED_EPSILON)
if (fabs(el - avg_dist) > tolerance)
defined_value = false;
break;
}
@@ -298,6 +300,11 @@ bool Bed3D::is_circle(const Pointfs& shape, Vec2d* center, double* radius)
return defined_value;
}
bool Bed3D::is_convex(const Pointfs& shape)
{
return Polygon::new_scale(shape).convex_points().size() == shape.size();
}
Bed3D::EShapeType Bed3D::detect_shape_type(const Pointfs& shape)
{
if (shape.size() < 3)