//------------------------------------------------------------------------------
// Lamp : Open source game middleware
// Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//------------------------------------------------------------------------------

/** @file
 * 交差ヘッダ
 * @author Junpee
 */

#ifndef INTERSECTION_H_
#define INTERSECTION_H_

#include <Core/Primitive/Vector3.h>

namespace Lamp{

//------------------------------------------------------------------------------
/**
 * 交差
 *
 * このクラスは継承しないで下さい。
 */
class Intersection{
public:
	/**
	 * コンストラクタ
	 *
	 * このコンストラクタは初期値の設定を行わないため値は不定です。
	 */
	Intersection(){}

	//--------------------------------------------------------------------------
	/**
	 * 設定
	 * @param position 交差位置
	 * @param refrection 反射
	 */
	void set(const Vector3& position, const Vector3& refrection){
		position_ = position;
		refrection_ = refrection;
	}

	/**
	 * 反転
	 */
	void reverse(){
		refrection_ = -refrection_;
		position_ = position_ + refrection_;
	}

	/**
	 * 比較
	 * @param compare 比較対象
	 * @return 同じ値であればtrueを返す
	 */
	inline bool operator ==(const Intersection& compare) const{
		return ((position_ == compare.position_) &&
			(refrection_ == compare.refrection_));
	}

	//--------------------------------------------------------------------------
	/**
	 * 交差位置の設定
	 * @param position 交差位置
	 */
	void setPosition(const Vector3& position){ position_ = position; }

	/**
	 * 交差位置の取得
	 * @return 交差位置
	 */
	const Vector3& getPosition() const{ return position_; }

	//--------------------------------------------------------------------------
	/**
	 * 反射の設定
	 * @param refrection 反射
	 */
	void setRefrection(const Vector3& refrection){ refrection_ = refrection; }

	/**
	 * 反射の取得
	 * @return 反射
	 */
	const Vector3& getRefrection() const{ return refrection_; }

private:
	//--------------------------------------------------------------------------
	// 交差位置
	Vector3 position_;
	// 反射
	Vector3 refrection_;

};

//------------------------------------------------------------------------------
} // End of namespace Lamp
#endif // End of INTERSECTION_H_
//------------------------------------------------------------------------------
