diff options
author | Thomas White <taw@physics.org> | 2010-01-14 10:29:24 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2010-01-14 10:29:24 +0100 |
commit | 1f5167c7b129f029758a92cecd6b037f14dada36 (patch) | |
tree | ff5b01d367762e244b9527ed4aac6ffeab2ec511 /src | |
parent | 2b9f975b8eddd9ea434198f3dca03b5a3950c351 (diff) |
Inline angle_between
Diffstat (limited to 'src')
-rw-r--r-- | src/utils.c | 10 | ||||
-rw-r--r-- | src/utils.h | 11 |
2 files changed, 9 insertions, 12 deletions
diff --git a/src/utils.c b/src/utils.c index c22bce71..de02ee6e 100644 --- a/src/utils.c +++ b/src/utils.c @@ -16,16 +16,6 @@ #include "utils.h" -/* Angle between two vectors. Answer in radians */ -double angle_between(double x1, double y1, double z1, - double x2, double y2, double z2) -{ - double mod1 = modulus(x1, y1, z1); - double mod2 = modulus(x2, y2, z2); - return acos( (x1*x2 + y1*y2 + z1*z2) / (mod1*mod2) ); -} - - size_t skipspace(const char *s) { size_t i; diff --git a/src/utils.h b/src/utils.h index 9aa07c8c..081d5a71 100644 --- a/src/utils.h +++ b/src/utils.h @@ -64,8 +64,6 @@ extern int quaternion_valid(struct quaternion q); /* --------------------------- Useful functions ----------------------------- */ -extern double angle_between(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 void progress_bar(int val, int total, const char *text); @@ -102,6 +100,15 @@ static inline double distance3d(double x1, double y1, double z1, return modulus(x1-x2, y1-y2, z1-z2); } +/* Answer in radians */ +static inline double angle_between(double x1, double y1, double z1, + double x2, double y2, double z2) +{ + double mod1 = modulus(x1, y1, z1); + double mod2 = modulus(x2, y2, z2); + return acos( (x1*x2 + y1*y2 + z1*z2) / (mod1*mod2) ); +} + /* ----------------------------- Useful macros ------------------------------ */ |