//-----------------------------------------------------------------------------------------------
// ConvexPolygon2D.hpp
//
#pragma once
#ifndef include_ConvexPolygon2D
#define include_ConvexPolygon2D

//-----------------------------------------------------------------------------------------------
#include "Engine/Core/MathBase.hpp"
#include "Engine/Core/Vector2.hpp"


/////////////////////////////////////////////////////////////////////////////////////////////////
class ConvexPolygon2D
{
public:
	// Constructors
	~ConvexPolygon2D() {}
	ConvexPolygon2D() {}
	ConvexPolygon2D( const ConvexPolygon2D& copy );
	explicit ConvexPolygon2D( const std::vector< Vector2 >& unorderedVertexes );
	explicit ConvexPolygon2D( const char* asText );

	// Mutators
	void SetFromText( const char* asText );
	void ClipToBackOfLine( const LineSegment2D& line );
	void ClipToFrontOfLine( const LineSegment2D& line );

	// Accessors

	// Operators
	const ConvexPolygon2D operator + ( const Vector2& translation ) const;
	const ConvexPolygon2D operator - ( const Vector2& antiTranslation ) const;
	void operator += ( const Vector2& translation );
	void operator -= ( const Vector2& antiTranslation );

	// External/friend functions and utilities

protected:
	Vector2 CalcLineCrossoverPoint( const LineSegment2D& line, const Vector2& pointOnOneSide, const Vector2& pointOnOtherSide ) const;

public:
	std::vector< Vector2 >	m_ccwVertexes;
};


/////////////////////////////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------------------------
inline ConvexPolygon2D::ConvexPolygon2D( const ConvexPolygon2D& copy )
	: m_ccwVertexes( copy.m_ccwVertexes )
{
}



#endif // include_Vector2
