~ubuntu-branches/ubuntu/trusty/libspnav/trusty

« back to all changes in this revision

Viewing changes to examples/cube/vmath.c

  • Committer: Bazaar Package Importer
  • Author(s): M G Berberich
  • Date: 2010-05-25 21:20:21 UTC
  • mto: (1.1.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20100525212021-g2sk0ukjkyr4ebkt
ImportĀ upstreamĀ versionĀ 0.2.2

Show diffs side-by-side

added added

removed removed

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