From: Mikko Rasa Date: Sat, 18 May 2013 18:33:37 +0000 (+0300) Subject: Add four-component members and constructor to Vector X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=959f6f9d250985e7324d4a07623bee5a5b00faca;p=libs%2Fmath.git Add four-component members and constructor to Vector --- diff --git a/source/linal/vector.h b/source/linal/vector.h index 11292f7..369e3ff 100644 --- a/source/linal/vector.h +++ b/source/linal/vector.h @@ -53,6 +53,20 @@ public: const T &operator[](unsigned i) const { return *(&x+i); } }; +template +class VectorComponents +{ +public: + T x, y, z, w; + +protected: + VectorComponents() { } + +public: + T &operator[](unsigned i) { return *(&x+i); } + const T &operator[](unsigned i) const { return *(&x+i); } +}; + /** A general mathematical vector. */ @@ -64,6 +78,7 @@ public: Vector(const T *); Vector(T, T); Vector(T, T, T); + Vector(T, T, T, T); template Vector(const Vector &); @@ -108,6 +123,15 @@ inline Vector::Vector(T x_, T y_, T z_) this->VectorComponents::z = z_; } +template +inline Vector::Vector(T x_, T y_, T z_, T w_) +{ + this->VectorComponents::x = x_; + this->VectorComponents::y = y_; + this->VectorComponents::z = z_; + this->VectorComponents::w = w_; +} + template template inline Vector::Vector(const Vector &v)