BedLeveling X/Y computation incorrect for linear

Computation for px and py for Bedleveling is creating incorrect grid for ZProbe sampling.
Note: It is using incorrect LOOP index (using BOTH ix and iy for both X and Y computations, rather than ix for X, and iy for Y)

#elif BED_LEVELING_METHOD == 1 // linear regression
float delta = 1.0 / (BED_LEVELING_GRID_SIZE - 1);
float ox = EEPROM::zProbeX1();
float oy = EEPROM::zProbeY1();
float ax = delta * (EEPROM::zProbeX2() - EEPROM::zProbeX1());
float ay = delta * (EEPROM::zProbeY2() - EEPROM::zProbeY1());
float bx = delta * (EEPROM::zProbeX3() - EEPROM::zProbeX1());
float by = delta * (EEPROM::zProbeY3() - EEPROM::zProbeY1());
for (int ix = 0; ix < BED_LEVELING_GRID_SIZE; ix++) {
for (int iy = 0; iy < BED_LEVELING_GRID_SIZE; iy++) {
//float px = ox + static_cast<float>(ix) * ax + static_cast<float>(iy) * bx;
float px = ox + static_cast<float>(ix) * ax + static_cast<float>(ix) * bx;
//float py = oy + static_cast<float>(iy) * ay + static_cast<float>(ix) * by;
float py = oy + static_cast<float>(iy) * ay + static_cast<float>(iy) * by;

Comments

  • No, 
    float px = ox + static_cast<float>(ix) * ax + static_cast<float>(iy) * bx;
    float py = oy + static_cast<float>(ix) * ay + static_cast<float>(iy) * by;

    is correct.
    A = P2-P1
    B = P3-P1

    POS = P1 + ix * A + iy * B

    is the equation spanning the measured parallelogram. And that is why ix and iy are required on all equations.
Sign In or Register to comment.