0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-03-13 01:40:09 +00:00

🧑‍💻 FLOAT_SQ macro

This commit is contained in:
Scott Lahteine 2024-05-15 15:21:39 -05:00
parent 6423b8031d
commit 5f96dffb9b
7 changed files with 14 additions and 13 deletions

View file

@ -89,7 +89,8 @@
#define HYPOT2(x,y) (sq(x)+sq(y))
#define NORMSQ(x,y,z) (sq(x)+sq(y)+sq(z))
#define CIRCLE_AREA(R) (float(M_PI) * sq(float(R)))
#define FLOAT_SQ(I) float(sq(I))
#define CIRCLE_AREA(R) (float(M_PI) * FLOAT_SQ(R))
#define CIRCLE_CIRC(R) (2 * float(M_PI) * float(R))
#define SIGN(a) ({__typeof__(a) _a = (a); (_a>0)-(_a<0);})

View file

@ -343,7 +343,7 @@ namespace ExtUI {
// This assumes the center is 0,0
#if ENABLED(DELTA)
if (axis != Z) {
max = SQRT(sq(float(PRINTABLE_RADIUS)) - sq(current_position[Y - axis])); // (Y - axis) == the other axis
max = SQRT(FLOAT_SQ(PRINTABLE_RADIUS) - sq(current_position[Y - axis])); // (Y - axis) == the other axis
min = -max;
}
#endif

View file

@ -63,7 +63,7 @@ void lcd_move_axis(const AxisEnum axis) {
// This assumes the center is 0,0
#if ENABLED(DELTA)
if (axis != Z_AXIS) {
max = SQRT(sq(float(PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
max = SQRT(FLOAT_SQ(PRINTABLE_RADIUS) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
min = -max;
}
#endif

View file

@ -129,7 +129,7 @@ void moveAxis(const AxisEnum axis, const int8_t direction) {
// This assumes the center is 0,0
#if ENABLED(DELTA)
if (axis != Z_AXIS && TERN1(HAS_EXTRUDERS, axis != E_AXIS)) {
max = SQRT(sq(float(PRINTABLE_RADIUS)) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
max = SQRT(FLOAT_SQ(PRINTABLE_RADIUS) - sq(current_position[Y_AXIS - axis])); // (Y_AXIS - axis) == the other axis
min = -max;
}
#endif

View file

@ -328,7 +328,7 @@ void report_current_position_projected() {
can_reach = (
R2 <= sq(L1 + L2) - inset
#if MIDDLE_DEAD_ZONE_R > 0
&& R2 >= sq(float(MIDDLE_DEAD_ZONE_R))
&& R2 >= FLOAT_SQ(MIDDLE_DEAD_ZONE_R)
#endif
);
@ -338,7 +338,7 @@ void report_current_position_projected() {
can_reach = (
R2 <= sq(L1 + L2) - inset
#if MIDDLE_DEAD_ZONE_R > 0
&& R2 >= sq(float(MIDDLE_DEAD_ZONE_R))
&& R2 >= FLOAT_SQ(MIDDLE_DEAD_ZONE_R)
#endif
);

View file

@ -818,10 +818,10 @@ void Planner::calculate_trapezoid_for_block(block_t * const block, const_float_t
if (accel != 0) {
inverse_accel = 1.0f / accel;
const float half_inverse_accel = 0.5f * inverse_accel,
nominal_rate_sq = sq(float(block->nominal_rate)),
nominal_rate_sq = FLOAT_SQ(block->nominal_rate),
// Steps required for acceleration, deceleration to/from nominal rate
decelerate_steps_float = half_inverse_accel * (nominal_rate_sq - sq(float(final_rate)));
float accelerate_steps_float = half_inverse_accel * (nominal_rate_sq - sq(float(initial_rate)));
decelerate_steps_float = half_inverse_accel * (nominal_rate_sq - FLOAT_SQ(final_rate));
float accelerate_steps_float = half_inverse_accel * (nominal_rate_sq - FLOAT_SQ(initial_rate));
accelerate_steps = CEIL(accelerate_steps_float);
decelerate_steps = FLOOR(decelerate_steps_float);

View file

@ -32,8 +32,8 @@ extern float segments_per_second;
#if ENABLED(AXEL_TPARA)
float constexpr L1 = TPARA_LINKAGE_1, L2 = TPARA_LINKAGE_2, // Float constants for Robot arm calculations
L1_2 = sq(float(L1)), L1_2_2 = 2.0 * L1_2,
L2_2 = sq(float(L2));
L1_2 = FLOAT_SQ(L1), L1_2_2 = 2.0 * L1_2,
L2_2 = FLOAT_SQ(L2);
void forward_kinematics(const_float_t a, const_float_t b, const_float_t c);
void home_TPARA();
@ -41,8 +41,8 @@ extern float segments_per_second;
#else
float constexpr L1 = SCARA_LINKAGE_1, L2 = SCARA_LINKAGE_2, // Float constants for SCARA calculations
L1_2 = sq(float(L1)), L1_2_2 = 2.0 * L1_2,
L2_2 = sq(float(L2));
L1_2 = FLOAT_SQ(L1), L1_2_2 = 2.0 * L1_2,
L2_2 = FLOAT_SQ(L2);
void forward_kinematics(const_float_t a, const_float_t b);