diff options
author | PolyFloyd <floyd@polyfloyd.net> | 2014-12-10 22:52:12 +0100 |
---|---|---|
committer | PolyFloyd <floyd@polyfloyd.net> | 2014-12-10 22:52:12 +0100 |
commit | 0c0048c746e7ad5a81666c95da724acc82263a33 (patch) | |
tree | 7710f36ccbe438695cd616b243d1a08d23929d72 | |
parent | 49c182396520245a96994dac57781a379205ffc9 (diff) | |
download | linmath-0c0048c746e7ad5a81666c95da724acc82263a33.tar.gz linmath-0c0048c746e7ad5a81666c95da724acc82263a33.tar.xz linmath-0c0048c746e7ad5a81666c95da724acc82263a33.zip |
Added quat_rotate
-rw-r--r-- | linmath.h | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -491,6 +491,14 @@ static inline void quat_conj(quat r, quat q) r[i] = -q[i]; r[3] = q[3]; } +static inline void quat_rotate(quat r, float angle, vec3 axis) { + vec3 v; + vec3_scale(v, axis, sinf(angle / 2)); + int i; + for(i=0; i<3; ++i) + r[i] = v[i]; + r[3] = cosf(angle / 2); +} #define quat_norm vec4_norm static inline void quat_mul_vec3(vec3 r, quat q, vec3 v) { |