aboutsummaryrefslogtreecommitdiff
path: root/src/utils.h
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2009-11-25 16:28:37 +0100
committerThomas White <taw@physics.org>2009-11-25 16:28:37 +0100
commit3e7ab3ad8fa154e0ae724757c8b7c8489b70fb99 (patch)
tree629f12f148e8f59ebdb6e0b219160ad1546452eb /src/utils.h
parent7d9b0d7ecd2bc7e7eacb5be56ce64fdaabea8624 (diff)
Tidy up utils module
Diffstat (limited to 'src/utils.h')
-rw-r--r--src/utils.h37
1 files changed, 23 insertions, 14 deletions
diff --git a/src/utils.h b/src/utils.h
index 8e9fb6cc..9e6458cf 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -48,26 +48,35 @@ struct quaternion
};
-extern unsigned int biggest(signed int a, signed int b);
-extern unsigned int smallest(signed int a, signed int b);
-extern double distance(double x1, double y1, double x2, double y2);
-extern double modulus(double x, double y, double z);
-extern double modulus_squared(double x, double y, double z);
+/* --------------------------- Useful functions ----------------------------- */
+
extern double angle_between(double x1, double y1, double z1,
double x2, double y2, double z2);
-extern double angle_between_d(double x1, double y1, double z1,
- double x2, double y2, double z2);
-extern double lambda(double voltage);
-extern double distance3d(double x1, double y1, double z1,
- double x2, double y2, double z2);
extern size_t skipspace(const char *s);
extern void chomp(char *s);
-extern int sign(double a);
-extern void mapping_rotate(double x, double y, double z,
- double *ddx, double *ddy, double *ddz,
- double omega, double tilt);
extern void progress_bar(int val, int total);
+/* Keep these ones inline, to avoid function call overhead */
+static inline double distance(double x1, double y1, double x2, double y2)
+{
+ return sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
+}
+
+static inline double modulus(double x, double y, double z)
+{
+ return sqrt(x*x + y*y + z*z);
+}
+
+static inline double modulus_squared(double x, double y, double z) {
+ return x*x + y*y + z*z;
+}
+
+static inline double distance3d(double x1, double y1, double z1,
+ double x2, double y2, double z2)
+{
+ return modulus(x1-x2, y1-y2, z1-z2);
+}
+
/* ----------------------------- Useful macros ------------------------------ */