From 68e6650df737450bfc469ce5228e9babea4a8966 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 4 Jul 2018 18:41:41 -0500 Subject: [PATCH] Remove Quake Fast Inverse SQRT (it isn't faster) --- Marlin/src/inc/Conditionals_post.h | 19 ------------------- Marlin/src/module/delta.cpp | 23 ----------------------- Marlin/src/module/delta.h | 13 +------------ 3 files changed, 1 insertion(+), 54 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 417fc59d96..b9972e2bcc 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1353,25 +1353,6 @@ #endif #endif -// Use float instead of double. Needs profiling. -#if defined(ARDUINO_ARCH_SAM) && ENABLED(DELTA_FAST_SQRT) - #undef ATAN2 - #undef FABS - #undef POW - #undef SQRT - #undef CEIL - #undef FLOOR - #undef LROUND - #undef FMOD - #define ATAN2(y, x) atan2f(y, x) - #define POW(x, y) powf(x, y) - #define SQRT(x) sqrtf(x) - #define CEIL(x) ceilf(x) - #define FLOOR(x) floorf(x) - #define LROUND(x) lroundf(x) - #define FMOD(x, y) fmodf(x, y) -#endif - // Number of VFAT entries used. Each entry has 13 UTF-16 characters #if ENABLED(SCROLL_LONG_FILENAMES) #define MAX_VFAT_ENTRIES (5) diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index f6e2d65a2b..2fe924a427 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -90,31 +90,8 @@ void recalc_delta_settings() { * * - Disable the home_offset (M206) and/or position_shift (G92) * features to remove up to 12 float additions. - * - * - Use a fast-inverse-sqrt function and add the reciprocal. - * (see above) */ -#if ENABLED(DELTA_FAST_SQRT) && defined(__AVR__) - /** - * Fast inverse sqrt from Quake III Arena - * See: https://en.wikipedia.org/wiki/Fast_inverse_square_root - */ - float Q_rsqrt(float number) { - long i; - float x2, y; - const float threehalfs = 1.5f; - x2 = number * 0.5f; - y = number; - i = * ( long * ) &y; // evil floating point bit level hacking - i = 0x5F3759DF - ( i >> 1 ); // what the f***? - y = * ( float * ) &i; - y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration - // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed - return y; - } -#endif - #define DELTA_DEBUG(VAR) do { \ SERIAL_ECHOPAIR("cartesian X:", VAR[X_AXIS]); \ SERIAL_ECHOPAIR(" Y:", VAR[Y_AXIS]); \ diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index 2c367fa8d4..cf62b5e621 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -64,19 +64,8 @@ void recalc_delta_settings(); * (see above) */ -#if ENABLED(DELTA_FAST_SQRT) && defined(__AVR__) - /** - * Fast inverse sqrt from Quake III Arena - * See: https://en.wikipedia.org/wiki/Fast_inverse_square_root - */ - float Q_rsqrt(float number); - #define _SQRT(n) (1.0f / Q_rsqrt(n)) -#else - #define _SQRT(n) SQRT(n) -#endif - // Macro to obtain the Z position of an individual tower -#define DELTA_Z(V,T) V[Z_AXIS] + _SQRT( \ +#define DELTA_Z(V,T) V[Z_AXIS] + SQRT( \ delta_diagonal_rod_2_tower[T] - HYPOT2( \ delta_tower[T][X_AXIS] - V[X_AXIS], \ delta_tower[T][Y_AXIS] - V[Y_AXIS] \