#ifndef GEOMETRY_H
#define GEOMETRY_H
#include <cmath>
typedef double Real;
class Vector2 {
public:
union {
struct { Real x, y; };
struct { Real c[2]; };
};
explicit Vector2(Real x = 0, Real y = 0):
x(x), y(y) { }
Real len_sqr() const { return x*x + y*y; }
Real len() const { return sqrt(len_sqr()); }
};
class Vector3 {
public:
union {
struct { Real x, y, z; };
struct { Real r, g, b; };
struct { Real c[3]; };
};
explicit Vector3(Real x = 0, Real y = 0, Real z = 0):
x(x), y(y), z(z) { }
};
class Vector4 {
public:
union {
struct { Real x, y, z, w; };
struct { Real r, g, b, a; };
struct { Real c[4]; };
};
explicit Vector4(Real x = 0, Real y = 0, Real z = 0, Real w = 0):
x(x), y(y), z(z), w(w) { }
};
#endif