vmath.c 332 B

12345678910111213141516
  1. #include <math.h>
  2. #include "vmath.h"
  3. quat_t quat_rotate(quat_t q, float angle, float x, float y, float z)
  4. {
  5. quat_t rq;
  6. float half_angle = angle * 0.5f;
  7. float sin_half = (float)sin(half_angle);
  8. rq.w = (float)cos(half_angle);
  9. rq.x = x * sin_half;
  10. rq.y = y * sin_half;
  11. rq.z = z * sin_half;
  12. return quat_mul(q, rq);
  13. }