clray
annotate src/vector.cc @ 35:7d77ded5f890
stopped using a heap to flatten the kdtree. added explicit left/right indices
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 26 Aug 2010 20:24:07 +0100 |
parents | |
children | 6a30f27fa1e6 |
rev | line source |
---|---|
nuclear@23 | 1 #include "vector.h" |
nuclear@23 | 2 |
nuclear@23 | 3 Vector2::Vector2() : x(0), y(0) {} |
nuclear@23 | 4 |
nuclear@23 | 5 Vector2::Vector2(float x, float y) |
nuclear@23 | 6 { |
nuclear@23 | 7 this->x = x; |
nuclear@23 | 8 this->y = y; |
nuclear@23 | 9 } |
nuclear@23 | 10 |
nuclear@23 | 11 |
nuclear@23 | 12 Vector3::Vector3() : x(0), y(0), z(0) {} |
nuclear@23 | 13 |
nuclear@23 | 14 Vector3::Vector3(float x, float y, float z) |
nuclear@23 | 15 { |
nuclear@23 | 16 this->x = x; |
nuclear@23 | 17 this->y = y; |
nuclear@23 | 18 this->z = z; |
nuclear@23 | 19 } |
nuclear@23 | 20 |
nuclear@23 | 21 void Vector3::normalize() |
nuclear@23 | 22 { |
nuclear@23 | 23 float len = sqrt(x * x + y * y + z * z); |
nuclear@23 | 24 if(len != 0.0) { |
nuclear@23 | 25 x /= len; |
nuclear@23 | 26 y /= len; |
nuclear@23 | 27 z /= len; |
nuclear@23 | 28 } |
nuclear@23 | 29 } |