clray
diff src/vector.h @ 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.h Fri Aug 13 18:20:45 2010 +0100 1.3 @@ -0,0 +1,37 @@ 1.4 +#ifndef VECTOR_H_ 1.5 +#define VECTOR_H_ 1.6 + 1.7 +class Vector2 { 1.8 +public: 1.9 + float x, y; 1.10 + 1.11 + Vector2(); 1.12 + Vector2(float x, float y); 1.13 +}; 1.14 + 1.15 +class Vector3 { 1.16 +public: 1.17 + float x, y, z; 1.18 + 1.19 + Vector3(); 1.20 + Vector3(float x, float y, float z); 1.21 + 1.22 + void normalize(); 1.23 + inline float length(); 1.24 + inline float lengthsq(); 1.25 +}; 1.26 + 1.27 +inline Vector3 operator +(const Vector3 &a, const Vector3 &b); 1.28 +inline Vector3 operator -(const Vector3 &a, const Vector3 &b); 1.29 +inline Vector3 operator *(const Vector3 &a, const Vector3 &b); 1.30 +inline Vector3 operator /(const Vector3 &a, const Vector3 &b); 1.31 + 1.32 +inline Vector3 operator -(const Vector3 &vec); 1.33 +inline Vector3 operator *(const Vector3 &vec, float s); 1.34 + 1.35 +inline float dot(const Vector3 &a, const Vector3 &b); 1.36 +inline Vector3 cross(const Vector3 &a, const Vector3 &b); 1.37 + 1.38 +#include "vector.inl" 1.39 + 1.40 +#endif /* VECTOR_H_ */