X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=progs%2Fdemos%2Fspaceball%2Fvmath.c;fp=progs%2Fdemos%2Fspaceball%2Fvmath.c;h=f4eb50fab504191293c5eccda9d6d6f4c361c5e4;hb=bb97ecab3add22cf774d3bb8bdb9d1be537cc524;hp=0000000000000000000000000000000000000000;hpb=727f754eabe4bb4751e2d286c8ab71f9ea6d8908;p=freeglut diff --git a/progs/demos/spaceball/vmath.c b/progs/demos/spaceball/vmath.c new file mode 100644 index 0000000..f4eb50f --- /dev/null +++ b/progs/demos/spaceball/vmath.c @@ -0,0 +1,16 @@ +#include +#include "vmath.h" + +quat_t quat_rotate(quat_t q, float angle, float x, float y, float z) +{ + quat_t rq; + float half_angle = angle * 0.5; + float sin_half = sin(half_angle); + + rq.w = cos(half_angle); + rq.x = x * sin_half; + rq.y = y * sin_half; + rq.z = z * sin_half; + + return quat_mul(q, rq); +}