~ubuntu-branches/ubuntu/gutsy/rss-glx/gutsy

« back to all changes in this revision

Viewing changes to reallyslick/cpp_src/rsQuat.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-11-30 18:21:27 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20051130182127-5iww7elbiyzej1lk
Tags: upstream-0.8.0
ImportĀ upstreamĀ versionĀ 0.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2002  Terence M. Welsh
3
 
 * Ported to Linux by Tugrul Galatali <tugrul@galatali.com>
4
 
 *
5
 
 * rsMath is free software; you can redistribute it and/or modify
6
 
 * it under the terms of the GNU General Public License version 2 as 
7
 
 * published by the Free Software Foundation.
8
 
 *
9
 
 * rsMath is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 
 */
18
 
 
19
 
#ifndef RSQUAT_H
20
 
#define RSQUAT_H
21
 
 
22
 
#include "rsVec.h"
23
 
 
24
 
class rsQuat;
25
 
class rsVec;
26
 
 
27
 
class rsQuat {
28
 
      public:
29
 
        float q[4];
30
 
 
31
 
          rsQuat ();
32
 
          rsQuat (float x, float y, float z, float w);
33
 
         ~rsQuat ();
34
 
        void set (float x, float y, float z, float w);  // x, y, z, w
35
 
        void copy (rsQuat);     // Copy another quaternion
36
 
        void make (float a, float x, float y, float z); // angle, axis
37
 
        void make (float a, const rsVec & v);
38
 
        void normalize ();
39
 
        void preMult (rsQuat & postQuat);       // Multiply this quaternion by
40
 
        // the passed quaternion
41
 
        // (this * passed)
42
 
        void postMult (rsQuat & preQuat);       // Multiply the passed quaternion
43
 
        // by this quaternion
44
 
        // (passed * this)
45
 
        void toMat (float *);   // Convert quaternion to array of 16 floats
46
 
        void fromMat (float *); // Convert array of 16 floats to quaternion
47
 
        void fromEuler (float, float, float);   // Convert from hpr angles
48
 
        void slerp (rsQuat, rsQuat, float);     // Interpolate first quaternion
49
 
        // to second using float from 0.0
50
 
        // to 1.0
51
 
 
52
 
        float &operator [] (int i) {
53
 
                return q[i];
54
 
        } const float &operator [] (int i)const {
55
 
                return q[i];
56
 
}};
57
 
 
58
 
#endif // RSQUAT_H