diff options
author | datenwolf <code+github@datenwolf.net> | 2016-02-07 23:10:32 +0100 |
---|---|---|
committer | datenwolf <code+github@datenwolf.net> | 2016-02-07 23:10:32 +0100 |
commit | 057dd680a1e809516d2a53286112a74eeef54f62 (patch) | |
tree | 5966a6d8f9e1c4467f17b1f47c1ab1160d15603d | |
parent | 6b5b43ba41d5a6334463203b15294b609f27f469 (diff) | |
parent | 757ac1911bf88c144690691874c61568bbcf80d1 (diff) | |
download | linmath-057dd680a1e809516d2a53286112a74eeef54f62.tar.gz linmath-057dd680a1e809516d2a53286112a74eeef54f62.tar.xz linmath-057dd680a1e809516d2a53286112a74eeef54f62.zip |
Merge pull request #24 from adrianbroher/master
Add vec{2,3,4} minimum and maximum functions
-rw-r--r-- | linmath.h | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -39,6 +39,18 @@ static inline void vec##n##_norm(vec##n r, vec##n const v) \ { \ float k = 1.0 / vec##n##_len(v); \ vec##n##_scale(r, v, k); \ +} \ +static inline void vec##n##_min(vec##n r, vec##n a, vec##n b) \ +{ \ + int i; \ + for(i=0; i<n; ++i) \ + r[i] = a[i]<b[i] ? a[i] : b[i]; \ +} \ +static inline void vec##n##_max(vec##n r, vec##n a, vec##n b) \ +{ \ + int i; \ + for(i=0; i<n; ++i) \ + r[i] = a[i]>b[i] ? a[i] : b[i]; \ } LINMATH_H_DEFINE_VEC(2) |