My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

least_squares_fit.h 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * Incremental Least Squares Best Fit By Roxy and Ed Williams
  24. *
  25. * This algorithm is high speed and has a very small code footprint.
  26. * Its results are identical to both the Iterative Least-Squares published
  27. * earlier by Roxy and the QR_SOLVE solution. If used in place of QR_SOLVE
  28. * it saves roughly 10K of program memory. And even better... the data
  29. * fed into the algorithm does not need to all be present at the same time.
  30. * A point can be probed and its values fed into the algorithm and then discarded.
  31. *
  32. */
  33. #include "MarlinConfig.h"
  34. #if ENABLED(AUTO_BED_LEVELING_UBL) // Currently only used by UBL, but is applicable to Grid Based (Linear) Bed Leveling
  35. #include "Marlin.h"
  36. #include "macros.h"
  37. #include <math.h>
  38. struct linear_fit_data {
  39. int n;
  40. float xbar, ybar, zbar,
  41. x2bar, y2bar, z2bar,
  42. xybar, xzbar, yzbar,
  43. max_absx, max_absy,
  44. A, B, D;
  45. };
  46. void incremental_LSF_reset(struct linear_fit_data *);
  47. void incremental_LSF(struct linear_fit_data *, float x, float y, float z);
  48. int finish_incremental_LSF(struct linear_fit_data *);
  49. #endif