volmetrics

diff src/vector.h @ 0:88d390af583f

Image loader
author Eleni Maria Stea <eleni@mutantstargoat.com>
date Sat, 11 Jan 2014 17:22:36 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/vector.h	Sat Jan 11 17:22:36 2014 +0200
     1.3 @@ -0,0 +1,68 @@
     1.4 +#ifndef VECTOR_H_
     1.5 +#define VECTOR_H_
     1.6 +
     1.7 +class Matrix4x4;
     1.8 +
     1.9 +class Vector3 {
    1.10 +public:
    1.11 +	float x,y,z;
    1.12 +	Vector3();
    1.13 +	Vector3(float x, float y, float z);
    1.14 +	void transform(const Matrix4x4 &tm);
    1.15 +	void printv();
    1.16 +};
    1.17 +
    1.18 +bool operator < (const Vector3 &a, const Vector3 &b);
    1.19 +bool operator > (const Vector3 &a, const Vector3 &b);
    1.20 +bool operator == (const Vector3 &a, const Vector3 &b);
    1.21 +
    1.22 +Vector3 operator + (const Vector3 &a, const Vector3 &b);
    1.23 +Vector3 operator - (const Vector3 &a, const Vector3 &b);
    1.24 +Vector3 operator - (const Vector3 &a);
    1.25 +Vector3 operator * (const Vector3 &a, const Vector3 &b);
    1.26 +Vector3 operator * (const Vector3 &a, float b);
    1.27 +Vector3 operator * (float b, const Vector3 &a);
    1.28 +Vector3 operator / (const Vector3 &a, float b);
    1.29 +
    1.30 +const Vector3 &operator += (Vector3 &a, const Vector3 &b);
    1.31 +
    1.32 +float length (const Vector3 &a);
    1.33 +float dot (const Vector3 &a, const Vector3 &b);
    1.34 +Vector3 cross (const Vector3 &a, const Vector3 &b);
    1.35 +Vector3 normalize (const Vector3 &a);
    1.36 +
    1.37 +Vector3 reflect(const Vector3 &v, const Vector3 &n);
    1.38 +
    1.39 +class Vector4 {
    1.40 +	public:
    1.41 +	float x, y, z, w;
    1.42 +	Vector4();
    1.43 +	Vector4(float x, float y, float z, float w);
    1.44 +	void transform(const Matrix4x4 &tm);
    1.45 +	void printv();
    1.46 +};
    1.47 +
    1.48 +bool operator < (const Vector4 &a, const Vector4 &b);
    1.49 +bool operator > (const Vector4 &a, const Vector4 &b);
    1.50 +bool operator == (const Vector4 &a, const Vector4 &b);
    1.51 +
    1.52 +Vector4 operator + (const Vector4 &a, const Vector4 &b);
    1.53 +Vector4 operator - (const Vector4 &a, const Vector4 &b);
    1.54 +Vector4 operator - (const Vector4 &a);
    1.55 +Vector4 operator * (const Vector4 &a, const Vector4 &b);
    1.56 +Vector4 operator * (const Vector4 &a, float b);
    1.57 +Vector4 operator * (float b, const Vector4 &a);
    1.58 +Vector4 operator / (const Vector4 &a, float b);
    1.59 +
    1.60 +const Vector4 &operator += (Vector4 &a, const Vector4 &b);
    1.61 +
    1.62 +float length (const Vector4 &a);
    1.63 +float dot (const Vector4 &a, const Vector4 &b);
    1.64 +Vector4 cross (const Vector4 &v1, const Vector4 &v2, const Vector4 &v3);
    1.65 +Vector4 normalize (const Vector4 &a);
    1.66 +
    1.67 +Vector4 reflect(const Vector4 &v, const Vector4 &n);
    1.68 +
    1.69 +
    1.70 +#endif
    1.71 +