-
Notifications
You must be signed in to change notification settings - Fork 0
/
Quaternion.h
59 lines (50 loc) · 1.83 KB
/
Quaternion.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef _QUATERNION_H_
#define _QUATERNION_H_ 1
#include "Vector3.h"
class Quaternion{
public:
Quaternion();
Quaternion(double _w,double _x,double _y,double _z);
Quaternion(double _angle,const Vector3 &_axis);
Quaternion(const Quaternion &_orig);
double operator[](int i)const;
double &operator[](int i);
void setW(double _w);
void setX(double _x);
void setY(double _y);
void setZ(double _z);
void setVector(const Vector3 &p);
double getW()const;
double getX()const;
double getY()const;
double getZ()const;
Vector3 getVector()const;
double getAngle()const;
Vector3 getAxis()const;
friend Quaternion operator+(const Quaternion &q1,const Quaternion &q2);
friend Quaternion operator-(const Quaternion &q1,const Quaternion &q2);
friend Quaternion operator*(const Quaternion &q1,double scale);
friend Quaternion operator*(double scale,const Quaternion &q1);
friend Quaternion operator*(const Quaternion &q1,const Quaternion &q2);
friend Quaternion operator/(const Quaternion &q1,double scale);
friend double dot(const Quaternion &q1,const Quaternion &q2);
friend bool operator==(const Quaternion &q1,const Quaternion &q2);
friend bool operator!=(const Quaternion &q1,const Quaternion &q2);
friend Quaternion log(const Quaternion &q1);
friend Quaternion exp(const Quaternion &q1);
const Quaternion &operator+()const;
Quaternion operator-()const;
Quaternion &operator+=(const Quaternion &q1);
Quaternion &operator-=(const Quaternion &q1);
Quaternion &operator*=(double scale);
Quaternion &operator*=(const Quaternion &q1);
Quaternion &operator/=(double scale);
double norm()const;
double sqrNorm()const;
Quaternion inverse()const;
friend Vector3 applyRotate(const Quaternion &q,const Vector3 &p);
friend Quaternion slerp(double t,const Quaternion &p,const Quaternion &q);
private:
double w,x,y,z;
};
#endif // _QUATERNION_H_