update code base to Marlin 2.0.9.2
This commit is contained in:
15
Marlin/src/libs/least_squares_fit.h
Executable file → Normal file
15
Marlin/src/libs/least_squares_fit.h
Executable file → Normal file
@@ -16,7 +16,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
@@ -30,7 +30,6 @@
|
||||
* it saves roughly 10K of program memory. And even better... the data
|
||||
* fed into the algorithm does not need to all be present at the same time.
|
||||
* A point can be probed and its values fed into the algorithm and then discarded.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
@@ -38,7 +37,7 @@
|
||||
|
||||
struct linear_fit_data {
|
||||
float xbar, ybar, zbar,
|
||||
x2bar, y2bar, z2bar,
|
||||
x2bar, y2bar,
|
||||
xybar, xzbar, yzbar,
|
||||
max_absx, max_absy,
|
||||
A, B, D, N;
|
||||
@@ -48,7 +47,7 @@ inline void incremental_LSF_reset(struct linear_fit_data *lsf) {
|
||||
memset(lsf, 0, sizeof(linear_fit_data));
|
||||
}
|
||||
|
||||
inline void incremental_WLSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z, const float &w) {
|
||||
inline void incremental_WLSF(struct linear_fit_data *lsf, const_float_t x, const_float_t y, const_float_t z, const_float_t w) {
|
||||
// weight each accumulator by factor w, including the "number" of samples
|
||||
// (analogous to calling inc_LSF twice with same values to weight it by 2X)
|
||||
const float wx = w * x, wy = w * y, wz = w * z;
|
||||
@@ -57,7 +56,6 @@ inline void incremental_WLSF(struct linear_fit_data *lsf, const float &x, const
|
||||
lsf->zbar += wz;
|
||||
lsf->x2bar += wx * x;
|
||||
lsf->y2bar += wy * y;
|
||||
lsf->z2bar += wz * z;
|
||||
lsf->xybar += wx * y;
|
||||
lsf->xzbar += wx * z;
|
||||
lsf->yzbar += wy * z;
|
||||
@@ -65,17 +63,16 @@ inline void incremental_WLSF(struct linear_fit_data *lsf, const float &x, const
|
||||
lsf->max_absx = _MAX(ABS(wx), lsf->max_absx);
|
||||
lsf->max_absy = _MAX(ABS(wy), lsf->max_absy);
|
||||
}
|
||||
inline void incremental_WLSF(struct linear_fit_data *lsf, const xy_pos_t &pos, const float &z, const float &w) {
|
||||
inline void incremental_WLSF(struct linear_fit_data *lsf, const xy_pos_t &pos, const_float_t z, const_float_t w) {
|
||||
incremental_WLSF(lsf, pos.x, pos.y, z, w);
|
||||
}
|
||||
|
||||
inline void incremental_LSF(struct linear_fit_data *lsf, const float &x, const float &y, const float &z) {
|
||||
inline void incremental_LSF(struct linear_fit_data *lsf, const_float_t x, const_float_t y, const_float_t z) {
|
||||
lsf->xbar += x;
|
||||
lsf->ybar += y;
|
||||
lsf->zbar += z;
|
||||
lsf->x2bar += sq(x);
|
||||
lsf->y2bar += sq(y);
|
||||
lsf->z2bar += sq(z);
|
||||
lsf->xybar += x * y;
|
||||
lsf->xzbar += x * z;
|
||||
lsf->yzbar += y * z;
|
||||
@@ -83,7 +80,7 @@ inline void incremental_LSF(struct linear_fit_data *lsf, const float &x, const f
|
||||
lsf->max_absy = _MAX(ABS(y), lsf->max_absy);
|
||||
lsf->N += 1.0;
|
||||
}
|
||||
inline void incremental_LSF(struct linear_fit_data *lsf, const xy_pos_t &pos, const float &z) {
|
||||
inline void incremental_LSF(struct linear_fit_data *lsf, const xy_pos_t &pos, const_float_t z) {
|
||||
incremental_LSF(lsf, pos.x, pos.y, z);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user