Skip to content

Commit

Permalink
Move apply_rotation_xyz into matrix_3x3
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and hliebscher committed Mar 31, 2021
1 parent 26a9b05 commit c1c6511
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ void unified_bed_leveling::smart_fill_mesh() {
DEBUG_DELAY(20);
}

apply_rotation_xyz(rotation, mx, my, mz);
rotation.apply_rotation_xyz(mx, my, mz);

if (DEBUGGING(LEVELING)) {
DEBUG_ECHOPAIR_F("after rotation = [", mx, 7);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ G29_TYPE GcodeSuite::G29() {
const int ind = abl.indexIntoAB[xx][yy];
xyz_float_t tmp = { abl.eqnAMatrix[ind + 0 * abl.abl_points],
abl.eqnAMatrix[ind + 1 * abl.abl_points], 0 };
apply_rotation_xyz(planner.bed_level_matrix, tmp);
planner.bed_level_matrix.apply_rotation_xyz(tmp);
if (get_min) NOMORE(min_diff, abl.eqnBVector[ind] - tmp.z);
const float subval = get_min ? abl.mean : tmp.z + min_diff,
diff = abl.eqnBVector[ind] - subval;
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/libs/vector_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ void vector_3::debug(PGM_P const title) {
* matrix_3x3
*/

void apply_rotation_xyz(const matrix_3x3 &matrix, float &_x, float &_y, float &_z) {
vector_3 vec = vector_3(_x, _y, _z); vec.apply_rotation(matrix);
void matrix_3x3::apply_rotation_xyz(float &_x, float &_y, float &_z) {
vector_3 vec = vector_3(_x, _y, _z); vec.apply_rotation(*this);
_x = vec.x; _y = vec.y; _z = vec.z;
}

Expand Down
10 changes: 4 additions & 6 deletions Marlin/src/libs/vector_3.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
class matrix_3x3;

struct vector_3 : xyz_float_t {

vector_3(const float &_x, const float &_y, const float &_z) { set(_x, _y, _z); }
vector_3(const xy_float_t &in) { set(in.x, in.y); }
vector_3(const xyz_float_t &in) { set(in.x, in.y, in.z); }
Expand Down Expand Up @@ -82,9 +81,8 @@ struct matrix_3x3 {
void set_to_identity();

void debug(PGM_P const title);
};

void apply_rotation_xyz(const matrix_3x3 &rotationMatrix, float &x, float &y, float &z);
FORCE_INLINE void apply_rotation_xyz(const matrix_3x3 &rotationMatrix, xyz_pos_t &pos) {
apply_rotation_xyz(rotationMatrix, pos.x, pos.y, pos.z);
}
void apply_rotation_xyz(float &x, float &y, float &z);

FORCE_INLINE void apply_rotation_xyz(xyz_pos_t &pos) { apply_rotation_xyz(pos.x, pos.y, pos.z); }
};
4 changes: 2 additions & 2 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,7 @@ void Planner::check_axes_activity() {
#if ABL_PLANAR

xy_pos_t d = raw - level_fulcrum;
apply_rotation_xyz(bed_level_matrix, d.x, d.y, raw.z);
bed_level_matrix.apply_rotation_xyz(d.x, d.y, raw.z);
raw = d + level_fulcrum;

#elif HAS_MESH
Expand Down Expand Up @@ -1571,7 +1571,7 @@ void Planner::check_axes_activity() {
matrix_3x3 inverse = matrix_3x3::transpose(bed_level_matrix);

xy_pos_t d = raw - level_fulcrum;
apply_rotation_xyz(inverse, d.x, d.y, raw.z);
inverse.apply_rotation_xyz(d.x, d.y, raw.z);
raw = d + level_fulcrum;

#elif HAS_MESH
Expand Down

0 comments on commit c1c6511

Please sign in to comment.