diff options
author | Marcel Metz <mmetz@adrian-broher.net> | 2016-01-26 18:53:34 +0100 |
---|---|---|
committer | Marcel Metz <mmetz@adrian-broher.net> | 2016-01-26 18:53:34 +0100 |
commit | 757ac1911bf88c144690691874c61568bbcf80d1 (patch) | |
tree | 5966a6d8f9e1c4467f17b1f47c1ab1160d15603d | |
parent | 6b5b43ba41d5a6334463203b15294b609f27f469 (diff) | |
download | linmath-757ac1911bf88c144690691874c61568bbcf80d1.tar.gz linmath-757ac1911bf88c144690691874c61568bbcf80d1.tar.xz linmath-757ac1911bf88c144690691874c61568bbcf80d1.zip |
Add vec{2,3,4} component wise 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) |