🏗️ Support for up to 6 linear axes (#19112)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
@@ -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,16 +63,16 @@ 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 };
|
||||
}
|
||||
|
||||
void vector_3::debug(PGM_P const title) {
|
||||
@@ -105,9 +104,9 @@ matrix_3x3 matrix_3x3::create_from_rows(const vector_3 &row_0, const vector_3 &r
|
||||
//row_1.debug(PSTR("row_1"));
|
||||
//row_2.debug(PSTR("row_2"));
|
||||
matrix_3x3 new_matrix;
|
||||
new_matrix.vectors[0] = row_0;
|
||||
new_matrix.vectors[1] = row_1;
|
||||
new_matrix.vectors[2] = row_2;
|
||||
new_matrix.vectors[0].x = row_0.x; new_matrix.vectors[1].y = row_0.y; new_matrix.vectors[2].z = row_0.z;
|
||||
new_matrix.vectors[3].x = row_1.x; new_matrix.vectors[4].y = row_1.y; new_matrix.vectors[5].z = row_1.z;
|
||||
new_matrix.vectors[6].x = row_2.x; new_matrix.vectors[7].y = row_2.y; new_matrix.vectors[8].z = row_2.z;
|
||||
//new_matrix.debug(PSTR("new_matrix"));
|
||||
return new_matrix;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user