clray

annotate src/vector.cc @ 40:1bcbb53b3505

segfault on exit?
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 27 Aug 2010 19:00:14 +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 }