/***********************************************************************************
 * 要は代入の後に、Normalizeしてるだけ、でも、使わないので破棄予定。
 ***********************************************************************************/

#if !defined ATS_VECTOR_H
#define ATS_VECTOR_H

#include "ats_point.h"

namespace ats
{
	template<class T>
	class Vector : public Point<T>
	{
	private:

	public:
		inline explicit Vector(const T=0, const T=0, const T=0);
		inline explicit Vector(const Vector<T>& a);
		inline explicit Vector(const Point<T>& a);
		virtual ~Vector();

		inline virtual void SetXYZ(const T x, const T y, const T z);

		inline virtual Vector<T>& operator= (const Vector<T>&);
		inline virtual Vector<T>& operator+=(const Vector<T>&);
		inline virtual Vector<T>& operator-=(const Vector<T>&);
		inline virtual Vector<T>& operator*=(const Vector<T>&);
		inline virtual Vector<T>& operator/=(const Vector<T>&);

		inline virtual Vector<T> operator+(const Vector<T>&) const;
		inline virtual Vector<T> operator-(const Vector<T>&) const;
		inline virtual Vector<T> operator*(const Vector<T>&) const;
		inline virtual Vector<T> operator/(const Vector<T>&) const;
	};

	// エイリアス ---------------------------------------------------------------------------
	typedef Vector<double> Vector3D;

	// implement ---------------------------------------------------------------------------

	// コンストラクタ・デストラクタ --------------------------------------------------------
	template<class T>
	Vector<T>::Vector(const T x, const T y, const T z)
	: Point<T>(x, y, z)
	{
		Normalize();
	}

	template<class T>
	Vector<T>::Vector(const Vector<T>& a)
	: Point<T>(a)
	{
		Normalize();
	}

	template<class T>
	Vector<T>::Vector(const Point<T>& a)
	: Point<T>(a)
	{
		Normalize();
	}

	template<class T>
	Vector<T>::~Vector()
	{
	}

	// アクセッサ -------------------------------------------------------------------
	template<class T>
	void Vector<T>::SetXYZ(const T x, const T y, const T z)
	{
		m_x = x;
		m_y = y;
		m_z = z;
		Normalize();
	}
	// 代入演算子 -------------------------------------------------------------------
	template<class T>
	Vector<T>& Vector<T>::operator= (const Vector<T>& a)
	{
		Point<T>::operator=(a);
		Normalize();
		return *this;
	}
	template<class T>
	Vector<T>& Vector<T>::operator+=(const Vector<T>& a)
	{
		Point<T>::operator+=(a);
		Normalize();
		return *this;
	}
	template<class T>
	Vector<T>& Vector<T>::operator-=(const Vector<T>& a)
	{
		Point<T>::operator-=(a);
		Normalize();
		return *this;
	}
	template<class T>
	Vector<T>& Vector<T>::operator*=(const Vector<T>& a)
	{
		Point<T>::operator*=(a);
		Normalize();
		return *this;
	}
	template<class T>
	Vector<T>& Vector<T>::operator/=(const Vector<T>& a)
	{
		Point<T>::operator/=(a);
		Normalize();
		return *this;
	}

	// 四則演算子 --------------------------------------------------------------------------------
	// コピーコンストラクタを呼び出した時点で、Normalize()は呼ばれている。
	template<class T>
	Vector<T> Vector<T>::operator+(const Vector<T>& a) const
	{
		return Vector<T>(Point<T>::operator+(a));
	}
	template<class T>
	Vector<T> Vector<T>::operator-(const Vector<T>& a) const
	{
		return Vector<T>(Point<T>::operator-(a));
	}
	template<class T>
	Vector<T> Vector<T>::operator*(const Vector<T>& a) const
	{
		return Vector<T>(Point<T>::operator*(a));
	}
	template<class T>
	Vector<T> Vector<T>::operator/(const Vector<T>& a) const
	{
		return Vector<T>(Point<T>::operator/(a));
	}
}
#endif // ATS_VECTOR_H
