summaryrefslogtreecommitdiffhomepage
path: root/SixenseSDK/src/sixense_simple3d/progs/demos/spaceball/vmath.c
blob: 7ef3c25e737f9d65857afce24a9f9d66178d501f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <math.h>
#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.5f;
  float sin_half = (float)sin(half_angle);

  rq.w = (float)cos(half_angle);
  rq.x = x * sin_half;
  rq.y = y * sin_half;
  rq.z = z * sin_half;

  return quat_mul(q, rq);
}