libvmath4

view src/quat.inl @ 0:4d6383605d64

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 05 Oct 2014 04:00:05 +0300
parents
children
line source
1 Quat::Quat()
2 {
3 x = y = z = 0.0f;
4 w = 1.0f;
5 }
7 Quat::Quat(float x, float y, float z, float w)
8 {
9 this->x = x;
10 this->y = y;
11 this->z = z;
12 this->w = w;
13 }
15 Quat::Quat(const float *v)
16 {
17 x = v[0];
18 y = v[1];
19 z = v[2];
20 w = v[3];
21 }
23 float &Quat::operator [](int idx)
24 {
25 switch(idx) {
26 case 1:
27 return y;
28 case 2:
29 return z;
30 case 3:
31 return w;
32 case 0:
33 default:
34 return x;
35 }
36 }
38 const float &Quat::operator [](int idx) const
39 {
40 switch(idx) {
41 case 1:
42 return y;
43 case 2:
44 return z;
45 case 3:
46 return w;
47 case 0:
48 default:
49 return x;
50 }
51 }