#ifndef VECTOR_2_H #define VECTOR_2_H #include "utility/logging/logging.h" #include "utility/Property.h" #include "utility/math/VectorBase.h" template class Vector2 : public VectorBase { public: Vector2(); Vector2(const T& x, const T& y); Vector2(const VectorBase& vector); Vector2(const Vector2& vector); virtual ~Vector2(); T getValue(const unsigned int index) const; void setValue(const unsigned int index, const T& value); T operator[](const unsigned int index); Property x; Property y; Vector2 normalize(); Vector2 normalized() const; template void operator=(const Vector2& other); protected: static const unsigned int m_xIndex = 0; static const unsigned int m_yIndex = 1; }; template Vector2::Vector2() : VectorBase() , x(&VectorBase::m_values[m_xIndex]) , y(&VectorBase::m_values[m_yIndex]) { setValue(m_xIndex, 0); setValue(m_yIndex, 0); } template Vector2::Vector2(const T& x, const T& y) : VectorBase() , x(&VectorBase::m_values[m_xIndex]) , y(&VectorBase::m_values[m_yIndex]) { setValue(m_xIndex, x); setValue(m_yIndex, y); } template Vector2::Vector2(const VectorBase& vector) : VectorBase(vector) , x(&VectorBase::m_values[m_xIndex]) , y(&VectorBase::m_values[m_yIndex]) { } template Vector2::Vector2(const Vector2& vector) : VectorBase(vector) , x(&VectorBase::m_values[m_xIndex]) , y(&VectorBase::m_values[m_yIndex]) { } template Vector2::~Vector2() { } template T Vector2::getValue(const unsigned int index) const { try { return VectorBase::getValue(index); } catch (std::exception& e) { LOG_ERROR(e.what()); return 0; } } template void Vector2::setValue(const unsigned int index, const T& value) { try { VectorBase::setValue(index, value); } catch (std::exception& e) { LOG_ERROR(e.what()); } } template T Vector2::operator[](const unsigned int index) { try { return VectorBase::getValue(index); } catch (std::exception& e) { LOG_ERROR(e.what()); return 0; } } template Vector2 Vector2::normalize() { return VectorBase::normalize(); } template Vector2 Vector2::normalized() const { return VectorBase::normalized(); } template template void Vector2::operator=(const Vector2& other) { this->assign(other); } typedef Vector2 Vec2f; typedef Vector2 Vec2i; #endif // VECTOR_2_H