update code base to Marlin 2.0.9.2

This commit is contained in:
Stefan Kalscheuer
2021-10-03 18:57:12 +02:00
parent b9d7ba838e
commit 7077da3591
2617 changed files with 332093 additions and 103438 deletions

34
Marlin/src/libs/vector_3.cpp Executable file → Normal file
View 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/>.
*
*/
@@ -52,10 +52,9 @@
*/
vector_3 vector_3::cross(const vector_3 &left, const vector_3 &right) {
const xyz_float_t &lv = left, &rv = right;
return vector_3(lv.y * rv.z - lv.z * rv.y, // YZ cross
lv.z * rv.x - lv.x * rv.z, // ZX cross
lv.x * rv.y - lv.y * rv.x); // XY cross
return vector_3(left.y * right.z - left.z * right.y, // YZ cross
left.z * right.x - left.x * right.z, // ZX cross
left.x * right.y - left.y * right.x); // XY cross
}
vector_3 vector_3::get_normal() const {
@@ -64,22 +63,20 @@ vector_3 vector_3::get_normal() const {
return normalized;
}
void vector_3::normalize() {
*this *= RSQRT(sq(x) + sq(y) + sq(z));
}
float vector_3::magnitude() const { return SQRT(sq(x) + sq(y) + sq(z)); }
void vector_3::normalize() { *this *= RSQRT(sq(x) + sq(y) + sq(z)); }
// Apply a rotation to the matrix
void vector_3::apply_rotation(const matrix_3x3 &matrix) {
const float _x = x, _y = y, _z = z;
*this = { matrix.vectors[0][0] * _x + matrix.vectors[1][0] * _y + matrix.vectors[2][0] * _z,
matrix.vectors[0][1] * _x + matrix.vectors[1][1] * _y + matrix.vectors[2][1] * _z,
matrix.vectors[0][2] * _x + matrix.vectors[1][2] * _y + matrix.vectors[2][2] * _z };
*this = { matrix.vectors[0].x * _x + matrix.vectors[1].x * _y + matrix.vectors[2].x * _z,
matrix.vectors[0].y * _x + matrix.vectors[1].y * _y + matrix.vectors[2].y * _z,
matrix.vectors[0].z * _x + matrix.vectors[1].z * _y + matrix.vectors[2].z * _z };
}
extern const char SP_X_STR[], SP_Y_STR[], SP_Z_STR[];
void vector_3::debug(PGM_P const title) {
serialprintPGM(title);
SERIAL_ECHOPGM_P(title);
SERIAL_ECHOPAIR_F_P(SP_X_STR, x, 6);
SERIAL_ECHOPAIR_F_P(SP_Y_STR, y, 6);
SERIAL_ECHOLNPAIR_F_P(SP_Z_STR, z, 6);
@@ -89,8 +86,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;
}
@@ -141,10 +138,7 @@ matrix_3x3 matrix_3x3::transpose(const matrix_3x3 &original) {
}
void matrix_3x3::debug(PGM_P const title) {
if (title != nullptr) {
serialprintPGM(title);
SERIAL_EOL();
}
if (title) SERIAL_ECHOLNPGM_P(title);
LOOP_L_N(i, 3) {
LOOP_L_N(j, 3) {
if (vectors[i][j] >= 0.0) SERIAL_CHAR('+');