Browse Source

Add HYPOT2 and float comparison macros

Scott Lahteine 8 years ago
parent
commit
413b61e64a
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      Marlin/macros.h

+ 6
- 1
Marlin/macros.h View File

55
 #endif
55
 #endif
56
 #define RADIANS(d) ((d)*M_PI/180.0)
56
 #define RADIANS(d) ((d)*M_PI/180.0)
57
 #define DEGREES(r) ((r)*180.0/M_PI)
57
 #define DEGREES(r) ((r)*180.0/M_PI)
58
-#define HYPOT(x,y) sqrt(sq(x)+sq(y))
58
+#define HYPOT2(x,y) (sq(x)+sq(y))
59
+#define HYPOT(x,y) sqrt(HYPOT2(x,y))
59
 
60
 
60
 // Macros to contrain values
61
 // Macros to contrain values
61
 #define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
62
 #define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
124
 #define MAX3(a, b, c)    max(max(a, b), c)
125
 #define MAX3(a, b, c)    max(max(a, b), c)
125
 #define MAX4(a, b, c, d) max(max(max(a, b), c), d)
126
 #define MAX4(a, b, c, d) max(max(max(a, b), c), d)
126
 
127
 
128
+#define UNEAR_ZERO(x) ((x) < 0.000001)
129
+#define NEAR_ZERO(x) ((x) > -0.000001 && (x) < 0.000001)
130
+#define NEAR(x,y) NEAR_ZERO((x)-(y))
131
+
127
 #endif //__MACROS_H
132
 #endif //__MACROS_H

Loading…
Cancel
Save