🏗️ Support for up to 6 linear axes (#19112)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
committed by
Scott Lahteine
parent
d3c56a76e7
commit
c1fca91103
@ -37,19 +37,27 @@ L64XX_Marlin L64xxManager;
|
||||
#include "../../module/planner.h"
|
||||
#include "../../HAL/shared/Delay.h"
|
||||
|
||||
static const char str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ",
|
||||
static const char LINEAR_AXIS_LIST(
|
||||
str_X[] PROGMEM = "X ", str_Y[] PROGMEM = "Y ", str_Z[] PROGMEM = "Z ",
|
||||
str_I[] PROGMEM = AXIS4_STR " ", str_J[] PROGMEM = AXIS5_STR " ", str_K[] PROGMEM = AXIS6_STR " "
|
||||
),
|
||||
str_X2[] PROGMEM = "X2", str_Y2[] PROGMEM = "Y2",
|
||||
str_Z2[] PROGMEM = "Z2", str_Z3[] PROGMEM = "Z3", str_Z4[] PROGMEM = "Z4",
|
||||
str_E0[] PROGMEM = "E0", str_E1[] PROGMEM = "E1",
|
||||
str_E2[] PROGMEM = "E2", str_E3[] PROGMEM = "E3",
|
||||
str_E4[] PROGMEM = "E4", str_E5[] PROGMEM = "E5",
|
||||
str_E6[] PROGMEM = "E6", str_E7[] PROGMEM = "E7"
|
||||
LIST_N(EXTRUDERS,
|
||||
str_E0[] PROGMEM = "E0", str_E1[] PROGMEM = "E1",
|
||||
str_E2[] PROGMEM = "E2", str_E3[] PROGMEM = "E3",
|
||||
str_E4[] PROGMEM = "E4", str_E5[] PROGMEM = "E5",
|
||||
str_E6[] PROGMEM = "E6", str_E7[] PROGMEM = "E7"
|
||||
)
|
||||
;
|
||||
|
||||
#define _EN_ITEM(N) , str_E##N
|
||||
PGM_P const L64XX_Marlin::index_to_axis[] PROGMEM = {
|
||||
str_X, str_Y, str_Z, str_X2, str_Y2, str_Z2, str_Z3, str_Z4,
|
||||
str_E0, str_E1, str_E2, str_E3, str_E4, str_E5, str_E6, str_E7
|
||||
LINEAR_AXIS_LIST(str_X, str_Y, str_Z, str_I, str_J, str_K),
|
||||
str_X2, str_Y2, str_Z2, str_Z3, str_Z4
|
||||
REPEAT(E_STEPPERS, _EN_ITEM)
|
||||
};
|
||||
#undef _EN_ITEM
|
||||
|
||||
#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
|
||||
#include "../../core/debug_out.h"
|
||||
@ -58,16 +66,17 @@ void echo_yes_no(const bool yes) { DEBUG_ECHOPGM_P(yes ? PSTR(" YES") : PSTR(" N
|
||||
|
||||
uint8_t L64XX_Marlin::dir_commands[MAX_L64XX]; // array to hold direction command for each driver
|
||||
|
||||
#define _EN_ITEM(N) , INVERT_E##N##_DIR
|
||||
const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = {
|
||||
INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR
|
||||
LINEAR_AXIS_LIST(INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR, INVERT_I_DIR, INVERT_J_DIR, INVERT_K_DIR)
|
||||
, (INVERT_X_DIR) ^ BOTH(X_DUAL_STEPPER_DRIVERS, INVERT_X2_VS_X_DIR) // X2
|
||||
, (INVERT_Y_DIR) ^ BOTH(Y_DUAL_STEPPER_DRIVERS, INVERT_Y2_VS_Y_DIR) // Y2
|
||||
, (INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2
|
||||
, (INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3
|
||||
, (INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4
|
||||
, INVERT_E0_DIR, INVERT_E1_DIR, INVERT_E2_DIR, INVERT_E3_DIR
|
||||
, INVERT_E4_DIR, INVERT_E5_DIR, INVERT_E6_DIR, INVERT_E7_DIR
|
||||
REPEAT(E_STEPPERS, _EN_ITEM)
|
||||
};
|
||||
#undef _EN_ITEM
|
||||
|
||||
volatile uint8_t L64XX_Marlin::spi_abort = false;
|
||||
uint8_t L64XX_Marlin::spi_active = false;
|
||||
@ -326,6 +335,15 @@ void L64XX_Marlin::set_param(const L64XX_axis_t axis, const uint8_t param, const
|
||||
#if AXIS_IS_L64XX(Z)
|
||||
case Z : SET_L6470_PARAM(Z); break;
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(I)
|
||||
case I : SET_L6470_PARAM(I); break;
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(J)
|
||||
case J : SET_L6470_PARAM(J); break;
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(K)
|
||||
case K : SET_L6470_PARAM(K); break;
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(X2)
|
||||
case X2: SET_L6470_PARAM(X2); break;
|
||||
#endif
|
||||
@ -370,8 +388,7 @@ void L64XX_Marlin::set_param(const L64XX_axis_t axis, const uint8_t param, const
|
||||
|
||||
inline void echo_min_max(const char a, const_float_t min, const_float_t max) {
|
||||
DEBUG_CHAR(' '); DEBUG_CHAR(a);
|
||||
DEBUG_ECHOPAIR(" min = ", min);
|
||||
DEBUG_ECHOLNPAIR(" max = ", max);
|
||||
DEBUG_ECHOLNPAIR(" min = ", min, " max = ", max);
|
||||
}
|
||||
inline void echo_oct_used(const_float_t oct, const uint8_t stall) {
|
||||
DEBUG_ECHOPAIR("over_current_threshold used : ", oct);
|
||||
@ -433,10 +450,15 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in
|
||||
// Position calcs & checks
|
||||
//
|
||||
|
||||
const float X_center = LOGICAL_X_POSITION(current_position.x),
|
||||
Y_center = LOGICAL_Y_POSITION(current_position.y),
|
||||
Z_center = LOGICAL_Z_POSITION(current_position.z),
|
||||
E_center = current_position.e;
|
||||
const float LOGICAL_AXIS_LIST(
|
||||
E_center = current_position.e,
|
||||
X_center = LOGICAL_X_POSITION(current_position.x),
|
||||
Y_center = LOGICAL_Y_POSITION(current_position.y),
|
||||
Z_center = LOGICAL_Z_POSITION(current_position.z),
|
||||
I_center = LOGICAL_I_POSITION(current_position.i),
|
||||
J_center = LOGICAL_J_POSITION(current_position.j),
|
||||
K_center = LOGICAL_K_POSITION(current_position.k)
|
||||
);
|
||||
|
||||
switch (axis_mon[0][0]) {
|
||||
default: position_max = position_min = 0; break;
|
||||
@ -451,31 +473,73 @@ uint8_t L64XX_Marlin::get_user_input(uint8_t &driver_count, L64XX_axis_t axis_in
|
||||
}
|
||||
} break;
|
||||
|
||||
case 'Y': {
|
||||
position_min = Y_center - displacement;
|
||||
position_max = Y_center + displacement;
|
||||
echo_min_max('Y', position_min, position_max);
|
||||
if (TERN0(HAS_ENDSTOPS, position_min < (Y_MIN_POS) || position_max > (Y_MAX_POS))) {
|
||||
err_out_of_bounds();
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
#if HAS_Y_AXIS
|
||||
case 'Y': {
|
||||
position_min = Y_center - displacement;
|
||||
position_max = Y_center + displacement;
|
||||
echo_min_max('Y', position_min, position_max);
|
||||
if (TERN0(HAS_ENDSTOPS, position_min < (Y_MIN_POS) || position_max > (Y_MAX_POS))) {
|
||||
err_out_of_bounds();
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
|
||||
case 'Z': {
|
||||
position_min = Z_center - displacement;
|
||||
position_max = Z_center + displacement;
|
||||
echo_min_max('Z', position_min, position_max);
|
||||
if (TERN0(HAS_ENDSTOPS, position_min < (Z_MIN_POS) || position_max > (Z_MAX_POS))) {
|
||||
err_out_of_bounds();
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
#if HAS_Z_AXIS
|
||||
case 'Z': {
|
||||
position_min = Z_center - displacement;
|
||||
position_max = Z_center + displacement;
|
||||
echo_min_max('Z', position_min, position_max);
|
||||
if (TERN0(HAS_ENDSTOPS, position_min < (Z_MIN_POS) || position_max > (Z_MAX_POS))) {
|
||||
err_out_of_bounds();
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
|
||||
case 'E': {
|
||||
position_min = E_center - displacement;
|
||||
position_max = E_center + displacement;
|
||||
echo_min_max('E', position_min, position_max);
|
||||
} break;
|
||||
#if LINEAR_AXES >= 4
|
||||
case AXIS4_NAME: {
|
||||
position_min = I_center - displacement;
|
||||
position_max = I_center + displacement;
|
||||
echo_min_max(AXIS4_NAME, position_min, position_max);
|
||||
if (TERN0(HAS_ENDSTOPS, position_min < (I_MIN_POS) || position_max > (I_MAX_POS))) {
|
||||
err_out_of_bounds();
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
|
||||
#if LINEAR_AXES >= 5
|
||||
case AXIS5_NAME: {
|
||||
position_min = J_center - displacement;
|
||||
position_max = J_center + displacement;
|
||||
echo_min_max(AXIS5_NAME, position_min, position_max);
|
||||
if (TERN1(HAS_ENDSTOPS, position_min < (J_MIN_POS) || position_max > (J_MAX_POS))) {
|
||||
err_out_of_bounds();
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
|
||||
#if LINEAR_AXES >= 6
|
||||
case AXIS6_NAME: {
|
||||
position_min = K_center - displacement;
|
||||
position_max = K_center + displacement;
|
||||
echo_min_max(AXIS6_NAME, position_min, position_max);
|
||||
if (TERN2(HAS_ENDSTOPS, position_min < (K_MIN_POS) || position_max > (K_MAX_POS))) {
|
||||
err_out_of_bounds();
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
#endif
|
||||
|
||||
#if HAS_EXTRUDERS
|
||||
case 'E': {
|
||||
position_min = E_center - displacement;
|
||||
position_max = E_center + displacement;
|
||||
echo_min_max('E', position_min, position_max);
|
||||
} break;
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
@ -660,7 +724,7 @@ void L64XX_Marlin::say_axis(const L64XX_axis_t axis, const uint8_t label/*=true*
|
||||
bool L64XX_Marlin::monitor_paused = false; // Flag to skip monitor during M122, M906, M916, M917, M918, etc.
|
||||
|
||||
struct L6470_driver_data {
|
||||
uint8_t driver_index;
|
||||
L64XX_axis_t driver_index;
|
||||
uint32_t driver_status;
|
||||
uint8_t is_otw;
|
||||
uint8_t otw_counter;
|
||||
@ -671,52 +735,61 @@ void L64XX_Marlin::say_axis(const L64XX_axis_t axis, const uint8_t label/*=true*
|
||||
|
||||
L6470_driver_data driver_L6470_data[] = {
|
||||
#if AXIS_IS_L64XX(X)
|
||||
{ 0, 0, 0, 0, 0, 0, 0 },
|
||||
{ X, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(Y)
|
||||
{ 1, 0, 0, 0, 0, 0, 0 },
|
||||
{ Y, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(Z)
|
||||
{ 2, 0, 0, 0, 0, 0, 0 },
|
||||
{ Z, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(I)
|
||||
{ I, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(J)
|
||||
{ J, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(K)
|
||||
{ K, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(X2)
|
||||
{ 3, 0, 0, 0, 0, 0, 0 },
|
||||
{ X2, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(Y2)
|
||||
{ 4, 0, 0, 0, 0, 0, 0 },
|
||||
{ Y2, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(Z2)
|
||||
{ 5, 0, 0, 0, 0, 0, 0 },
|
||||
{ Z2, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(Z3)
|
||||
{ 6, 0, 0, 0, 0, 0, 0 },
|
||||
{ Z3, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(Z4)
|
||||
{ 7, 0, 0, 0, 0, 0, 0 },
|
||||
{ Z4, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(E0)
|
||||
{ 8, 0, 0, 0, 0, 0, 0 },
|
||||
{ E0, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(E1)
|
||||
{ 9, 0, 0, 0, 0, 0, 0 },
|
||||
{ E1, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(E2)
|
||||
{ 10, 0, 0, 0, 0, 0, 0 },
|
||||
{ E2, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(E3)
|
||||
{ 11, 0, 0, 0, 0, 0, 0 },
|
||||
{ E3, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(E4)
|
||||
{ 12, 0, 0, 0, 0, 0, 0 },
|
||||
{ E4, 0, 0, 0, 0, 0, 0 },
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(E5)
|
||||
{ 13, 0, 0, 0, 0, 0, 0 }
|
||||
{ E5, 0, 0, 0, 0, 0, 0 }
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(E6)
|
||||
{ 14, 0, 0, 0, 0, 0, 0 }
|
||||
{ E6, 0, 0, 0, 0, 0, 0 }
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(E7)
|
||||
{ 16, 0, 0, 0, 0, 0, 0 }
|
||||
{ E7, 0, 0, 0, 0, 0, 0 }
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -863,6 +936,15 @@ void L64XX_Marlin::say_axis(const L64XX_axis_t axis, const uint8_t label/*=true*
|
||||
#if AXIS_IS_L64XX(Z)
|
||||
monitor_update(Z);
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(I)
|
||||
monitor_update(I);
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(J)
|
||||
monitor_update(J);
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(K)
|
||||
monitor_update(K);
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(X2)
|
||||
monitor_update(X2);
|
||||
#endif
|
||||
@ -896,6 +978,12 @@ void L64XX_Marlin::say_axis(const L64XX_axis_t axis, const uint8_t label/*=true*
|
||||
#if AXIS_IS_L64XX(E5)
|
||||
monitor_update(E5);
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(E6)
|
||||
monitor_update(E6);
|
||||
#endif
|
||||
#if AXIS_IS_L64XX(E7)
|
||||
monitor_update(E7);
|
||||
#endif
|
||||
|
||||
if (TERN0(L6470_DEBUG, report_L6470_status)) DEBUG_EOL();
|
||||
|
||||
|
@ -35,7 +35,9 @@
|
||||
#define dSPIN_STEP_CLOCK_REV dSPIN_STEP_CLOCK+1
|
||||
#define HAS_L64XX_EXTRUDER (AXIS_IS_L64XX(E0) || AXIS_IS_L64XX(E1) || AXIS_IS_L64XX(E2) || AXIS_IS_L64XX(E3) || AXIS_IS_L64XX(E4) || AXIS_IS_L64XX(E5) || AXIS_IS_L64XX(E6) || AXIS_IS_L64XX(E7))
|
||||
|
||||
enum L64XX_axis_t : uint8_t { X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7, MAX_L64XX };
|
||||
#define _EN_ITEM(N) , E##N
|
||||
enum L64XX_axis_t : uint8_t { LINEAR_AXIS_LIST(X, Y, Z, I, J, K), X2, Y2, Z2, Z3, Z4 REPEAT(E_STEPPERS, _EN_ITEM), MAX_L64XX };
|
||||
#undef _EN_ITEM
|
||||
|
||||
class L64XX_Marlin : public L64XXHelper {
|
||||
public:
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -44,12 +44,16 @@
|
||||
|
||||
class matrix_3x3;
|
||||
|
||||
struct vector_3 : xyz_float_t {
|
||||
vector_3(const_float_t _x, const_float_t _y, const_float_t _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); }
|
||||
vector_3(const xyze_float_t &in) { set(in.x, in.y, in.z); }
|
||||
vector_3() { reset(); }
|
||||
struct vector_3 {
|
||||
union {
|
||||
struct { float x, y, z; };
|
||||
float pos[3];
|
||||
};
|
||||
vector_3(const_float_t _x, const_float_t _y, const_float_t _z) : x(_x), y(_y), z(_z) {}
|
||||
vector_3(const xy_float_t &in) { x = in.x; TERN_(HAS_Y_AXIS, y = in.y); }
|
||||
vector_3(const xyz_float_t &in) { x = in.x; TERN_(HAS_Y_AXIS, y = in.y); TERN_(HAS_Z_AXIS, z = in.z); }
|
||||
vector_3(const xyze_float_t &in) { x = in.x; TERN_(HAS_Y_AXIS, y = in.y); TERN_(HAS_Z_AXIS, z = in.z); }
|
||||
vector_3() { x = y = z = 0; }
|
||||
|
||||
// Factory method
|
||||
static vector_3 cross(const vector_3 &a, const vector_3 &b);
|
||||
@ -59,19 +63,26 @@ struct vector_3 : xyz_float_t {
|
||||
void apply_rotation(const matrix_3x3 &matrix);
|
||||
|
||||
// Accessors
|
||||
float get_length() const;
|
||||
float magnitude() const;
|
||||
vector_3 get_normal() const;
|
||||
|
||||
// Operators
|
||||
FORCE_INLINE vector_3 operator+(const vector_3 &v) const { vector_3 o = *this; o += v; return o; }
|
||||
FORCE_INLINE vector_3 operator-(const vector_3 &v) const { vector_3 o = *this; o -= v; return o; }
|
||||
FORCE_INLINE vector_3 operator*(const float &v) const { vector_3 o = *this; o *= v; return o; }
|
||||
float& operator[](const int n) { return pos[n]; }
|
||||
const float& operator[](const int n) const { return pos[n]; }
|
||||
|
||||
vector_3& operator*=(const float &v) { x *= v; y *= v; z *= v; return *this; }
|
||||
vector_3 operator+(const vector_3 &v) { return vector_3(x + v.x, y + v.y, z + v.z); }
|
||||
vector_3 operator-(const vector_3 &v) { return vector_3(x - v.x, y - v.y, z - v.z); }
|
||||
vector_3 operator*(const float &v) { return vector_3(x * v, y * v, z * v); }
|
||||
|
||||
operator xy_float_t() { return xy_float_t({ x, y }); }
|
||||
operator xyz_float_t() { return xyz_float_t({ x, y, z }); }
|
||||
|
||||
void debug(PGM_P const title);
|
||||
};
|
||||
|
||||
struct matrix_3x3 {
|
||||
abc_float_t vectors[3];
|
||||
vector_3 vectors[3];
|
||||
|
||||
// Factory methods
|
||||
static matrix_3x3 create_from_rows(const vector_3 &row_0, const vector_3 &row_1, const vector_3 &row_2);
|
||||
@ -83,6 +94,4 @@ struct matrix_3x3 {
|
||||
void debug(PGM_P const title);
|
||||
|
||||
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); }
|
||||
};
|
||||
|
Reference in New Issue
Block a user