libvmath4
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/quat.inl Sun Oct 05 04:00:05 2014 +0300 1.3 @@ -0,0 +1,51 @@ 1.4 +Quat::Quat() 1.5 +{ 1.6 + x = y = z = 0.0f; 1.7 + w = 1.0f; 1.8 +} 1.9 + 1.10 +Quat::Quat(float x, float y, float z, float w) 1.11 +{ 1.12 + this->x = x; 1.13 + this->y = y; 1.14 + this->z = z; 1.15 + this->w = w; 1.16 +} 1.17 + 1.18 +Quat::Quat(const float *v) 1.19 +{ 1.20 + x = v[0]; 1.21 + y = v[1]; 1.22 + z = v[2]; 1.23 + w = v[3]; 1.24 +} 1.25 + 1.26 +float &Quat::operator [](int idx) 1.27 +{ 1.28 + switch(idx) { 1.29 + case 1: 1.30 + return y; 1.31 + case 2: 1.32 + return z; 1.33 + case 3: 1.34 + return w; 1.35 + case 0: 1.36 + default: 1.37 + return x; 1.38 + } 1.39 +} 1.40 + 1.41 +const float &Quat::operator [](int idx) const 1.42 +{ 1.43 + switch(idx) { 1.44 + case 1: 1.45 + return y; 1.46 + case 2: 1.47 + return z; 1.48 + case 3: 1.49 + return w; 1.50 + case 0: 1.51 + default: 1.52 + return x; 1.53 + } 1.54 +}