@@ -99,6 +99,7 @@ void HangprinterKinematics::Init() noexcept
99
99
constexpr float DefaultTorqueConstants[HANGPRINTER_AXES] = { 0 .0F };
100
100
101
101
ARRAY_INIT (anchors, DefaultAnchors);
102
+ anchorMode = HangprinterAnchorMode::LastOnTop;
102
103
printRadius = DefaultPrintRadius;
103
104
spoolBuildupFactor = DefaultSpoolBuildupFactor;
104
105
ARRAY_INIT (spoolRadii, DefaultSpoolRadii);
@@ -419,25 +420,51 @@ static bool isSameSide(float const v0[3], float const v1[3], float const v2[3],
419
420
return dot0*dot1 > 0 .0F ;
420
421
}
421
422
422
- // For each triangle side in a pseudo-pyramid, check if the point is inside the pyramid (Except for the base)
423
- // Also check that any point below the line between two exterior anchors (all anchors are exterior except for the last one)
424
- // is in the "inside part" all the way down to min_Z, however low it may be.
425
- // To further limit the movements in the X and Y axes one can simply set a smaller print radius.
426
- bool HangprinterKinematics::IsReachable (float axesCoords[MaxAxes], AxesBitmap axes) const noexcept /* override*/
423
+ bool HangprinterKinematics::IsInsidePyramidSides (float const coords[3 ]) const noexcept
427
424
{
428
- float const coords[3 ] = {axesCoords[X_AXIS], axesCoords[Y_AXIS], axesCoords[Z_AXIS]};
429
425
bool reachable = true ;
430
426
431
427
// Check all the planes defined by triangle sides in the pyramid
432
428
for (size_t i = 0 ; reachable && i < HANGPRINTER_AXES - 1 ; ++i) {
433
429
reachable = reachable && isSameSide (anchors[i], anchors[(i+1 ) % (HANGPRINTER_AXES - 1 )], anchors[HANGPRINTER_AXES - 1 ], anchors[(i+2 ) % (HANGPRINTER_AXES - 1 )], coords);
434
430
}
431
+ return reachable;
432
+ }
433
+
434
+ bool HangprinterKinematics::IsInsidePrismSides (float const coords[3 ], unsigned const discount_last) const noexcept
435
+ {
436
+ bool reachable = true ;
435
437
436
438
// For each side of the base, check the plane formed by side and another point bellow them in z.
437
- for (size_t i = 0 ; reachable && i < HANGPRINTER_AXES - 1 ; ++i) {
439
+ for (size_t i = 0 ; reachable && i < HANGPRINTER_AXES - discount_last ; ++i) {
438
440
float const lower_point[3 ] = {anchors[i][0 ], anchors[i][1 ], anchors[i][2 ] - 1 };
439
441
reachable = reachable && isSameSide (anchors[i], anchors[(i+1 ) % (HANGPRINTER_AXES - 1 )], lower_point, anchors[(i+2 ) % (HANGPRINTER_AXES - 1 )], coords);
440
442
}
443
+ return reachable;
444
+ }
445
+
446
+ // For each triangle side in a pseudo-pyramid, check if the point is inside the pyramid (Except for the base)
447
+ // Also check that any point below the line between two exterior anchors (all anchors are exterior except for the last one)
448
+ // is in the "inside part" all the way down to min_Z, however low it may be.
449
+ // To further limit the movements in the X and Y axes one can simply set a smaller print radius.
450
+ bool HangprinterKinematics::IsReachable (float axesCoords[MaxAxes], AxesBitmap axes) const noexcept /* override*/
451
+ {
452
+ float const coords[3 ] = {axesCoords[X_AXIS], axesCoords[Y_AXIS], axesCoords[Z_AXIS]};
453
+ bool reachable = true ;
454
+
455
+ switch (anchorMode) {
456
+ case HangprinterAnchorMode::None:
457
+ return true ;
458
+
459
+ // This reaches a pyramid on top of the lower prism if the bed is below the lower anchors
460
+ case HangprinterAnchorMode::LastOnTop:
461
+ default :
462
+ reachable = reachable && IsInsidePyramidSides (coords);
463
+ reachable = reachable && IsInsidePrismSides (coords, 1 );
464
+
465
+ case HangprinterAnchorMode::AllOnTop:
466
+ reachable = reachable && IsInsidePrismSides (coords, 0 );
467
+ };
441
468
442
469
return reachable;
443
470
}
0 commit comments