Przeglądaj źródła

Remove Quake Fast Inverse SQRT (it isn't faster)

Scott Lahteine 6 lat temu
rodzic
commit
68e6650df7

+ 0
- 19
Marlin/src/inc/Conditionals_post.h Wyświetl plik

1353
   #endif
1353
   #endif
1354
 #endif
1354
 #endif
1355
 
1355
 
1356
-// Use float instead of double. Needs profiling.
1357
-#if defined(ARDUINO_ARCH_SAM) && ENABLED(DELTA_FAST_SQRT)
1358
-  #undef ATAN2
1359
-  #undef FABS
1360
-  #undef POW
1361
-  #undef SQRT
1362
-  #undef CEIL
1363
-  #undef FLOOR
1364
-  #undef LROUND
1365
-  #undef FMOD
1366
-  #define ATAN2(y, x) atan2f(y, x)
1367
-  #define POW(x, y) powf(x, y)
1368
-  #define SQRT(x) sqrtf(x)
1369
-  #define CEIL(x) ceilf(x)
1370
-  #define FLOOR(x) floorf(x)
1371
-  #define LROUND(x) lroundf(x)
1372
-  #define FMOD(x, y) fmodf(x, y)
1373
-#endif
1374
-
1375
 // Number of VFAT entries used. Each entry has 13 UTF-16 characters
1356
 // Number of VFAT entries used. Each entry has 13 UTF-16 characters
1376
 #if ENABLED(SCROLL_LONG_FILENAMES)
1357
 #if ENABLED(SCROLL_LONG_FILENAMES)
1377
   #define MAX_VFAT_ENTRIES (5)
1358
   #define MAX_VFAT_ENTRIES (5)

+ 0
- 23
Marlin/src/module/delta.cpp Wyświetl plik

90
  *
90
  *
91
  * - Disable the home_offset (M206) and/or position_shift (G92)
91
  * - Disable the home_offset (M206) and/or position_shift (G92)
92
  *   features to remove up to 12 float additions.
92
  *   features to remove up to 12 float additions.
93
- *
94
- * - Use a fast-inverse-sqrt function and add the reciprocal.
95
- *   (see above)
96
  */
93
  */
97
 
94
 
98
-#if ENABLED(DELTA_FAST_SQRT) && defined(__AVR__)
99
-  /**
100
-   * Fast inverse sqrt from Quake III Arena
101
-   * See: https://en.wikipedia.org/wiki/Fast_inverse_square_root
102
-   */
103
-  float Q_rsqrt(float number) {
104
-    long i;
105
-    float x2, y;
106
-    const float threehalfs = 1.5f;
107
-    x2 = number * 0.5f;
108
-    y  = number;
109
-    i  = * ( long * ) &y;                       // evil floating point bit level hacking
110
-    i  = 0x5F3759DF - ( i >> 1 );               // what the f***?
111
-    y  = * ( float * ) &i;
112
-    y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
113
-    // y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed
114
-    return y;
115
-  }
116
-#endif
117
-
118
 #define DELTA_DEBUG(VAR) do { \
95
 #define DELTA_DEBUG(VAR) do { \
119
     SERIAL_ECHOPAIR("cartesian X:", VAR[X_AXIS]); \
96
     SERIAL_ECHOPAIR("cartesian X:", VAR[X_AXIS]); \
120
     SERIAL_ECHOPAIR(" Y:", VAR[Y_AXIS]);          \
97
     SERIAL_ECHOPAIR(" Y:", VAR[Y_AXIS]);          \

+ 1
- 12
Marlin/src/module/delta.h Wyświetl plik

64
  *   (see above)
64
  *   (see above)
65
  */
65
  */
66
 
66
 
67
-#if ENABLED(DELTA_FAST_SQRT) && defined(__AVR__)
68
-  /**
69
-   * Fast inverse sqrt from Quake III Arena
70
-   * See: https://en.wikipedia.org/wiki/Fast_inverse_square_root
71
-   */
72
-  float Q_rsqrt(float number);
73
-  #define _SQRT(n) (1.0f / Q_rsqrt(n))
74
-#else
75
-  #define _SQRT(n) SQRT(n)
76
-#endif
77
-
78
 // Macro to obtain the Z position of an individual tower
67
 // Macro to obtain the Z position of an individual tower
79
-#define DELTA_Z(V,T) V[Z_AXIS] + _SQRT(   \
68
+#define DELTA_Z(V,T) V[Z_AXIS] + SQRT(   \
80
   delta_diagonal_rod_2_tower[T] - HYPOT2( \
69
   delta_diagonal_rod_2_tower[T] - HYPOT2( \
81
       delta_tower[T][X_AXIS] - V[X_AXIS], \
70
       delta_tower[T][X_AXIS] - V[X_AXIS], \
82
       delta_tower[T][Y_AXIS] - V[Y_AXIS]  \
71
       delta_tower[T][Y_AXIS] - V[Y_AXIS]  \

Ładowanie…
Anuluj
Zapisz