clray

diff src/vector.cc @ 23:51f115e337c2

separated obj loading and vector class
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 13 Aug 2010 18:20:45 +0100
parents
children 6a30f27fa1e6
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/vector.cc	Fri Aug 13 18:20:45 2010 +0100
     1.3 @@ -0,0 +1,29 @@
     1.4 +#include "vector.h"
     1.5 +
     1.6 +Vector2::Vector2() : x(0), y(0) {}
     1.7 +
     1.8 +Vector2::Vector2(float x, float y)
     1.9 +{
    1.10 +	this->x = x;
    1.11 +	this->y = y;
    1.12 +}
    1.13 +
    1.14 +
    1.15 +Vector3::Vector3() : x(0), y(0), z(0) {}
    1.16 +
    1.17 +Vector3::Vector3(float x, float y, float z)
    1.18 +{
    1.19 +	this->x = x;
    1.20 +	this->y = y;
    1.21 +	this->z = z;
    1.22 +}
    1.23 +
    1.24 +void Vector3::normalize()
    1.25 +{
    1.26 +	float len = sqrt(x * x + y * y + z * z);
    1.27 +	if(len != 0.0) {
    1.28 +		x /= len;
    1.29 +		y /= len;
    1.30 +		z /= len;
    1.31 +	}
    1.32 +}