From 959f6f9d250985e7324d4a07623bee5a5b00faca Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 18 May 2013 21:33:37 +0300 Subject: [PATCH] Add four-component members and constructor to Vector --- source/linal/vector.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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) -- 2.45.2