/// @Desc :  Class represents 2d line.
/// @Package: Core

class Line2D<T>
{
public:
	///@Purpose: start is the start point of line
	///@Return: end is the end point of line
	Point2D<T> start, end;
 
	///----------------------------------------------------
	/// Constructors 
	///----------------------------------------------------
	
	
	
	
	
	///----------------------------------------------------
	/// Line2D Methods
	///----------------------------------------------------
	
	///@Purpose: check if passed point fall in current line
	///@Return:  true is it is, false otherwise
	boolean isPointInLine( Point2D<T> p);
 
	///@Purpose: check if passed line is contained in current line (part of me)
	///@Return:  true if it is, false otherwise
	boolean isLineInMe( Line2D<S> l);
 
	///@Purpose: get line center point, in physics called center of gravity
	///@Return:  Point2D object, otherwise false
	Point2D<T> getCenterPoint();	
 
	///@Purpose: get line length
	///@Return: line length
	float getLineLenght();
 
	///@Purpose: increase line length by value
	void increase(T value);
	
	///@Purpose: decrease line length by value
	void decrease(T value);
 
	///@Purpose: move start point of line to new position
	void move ( Point2D<T> p );
 
	///@Purpose: get current line slop
	float getLineSlope();
 
	///@Purpose: is passed line is perpendicular to current line
	///@Return:  true if it is, false otherwise
	boolean isPerpendicular( Line2D<T> l );
 
	///@Purpose: get point that current line and passed line are perpendicular in
	///@Return:  point object if exist
	Point2D<T> getPerpendicularPoint( Line2D<T> l );
 
	///@Purpose: get point that current line and passed line and intersect in
	///@Return:  point object if exist, null otherwise
	Point2D<T> getIntersectPoint ( Line2D<T> l );
 
   ///@Purpose: calculate the slope of a line given 2 points  
   ///@Parameters:  P1 is the first point,P2 is the second point
   ///@Return:the slope between our 2 points 
    static double slopeBetweenPoints(Point2D P1, Point2D P2);
   

   /// @Purpose: to determine whether two lines are perpendicular  
   /// @Parameters:  line1 : the first line 
   ///               line2 : the second line
   /// @Return : true  : if the lines are perpendicular
   ///           false : otherwise.
   
   static boolean    arePerp([IN] Line2D<T> line1,[IN] Line2D<T> line2);
   
   
   /// @Purpose: find the point of intersection between two lines  
   /// @Parameters:  line1 : the first line 
   ///               line2 : the second line
   /// @Return : the point of intersection 
   static Point2D<T> lineIntersect([IN] Line2D<T> line1,[IN] Line2D<T> line2);
   
    ///@ purpose:  calculate the y-intercept of the current line
    ///@ Parameters: point:  any point that belong to the line
    ///@ Return: the y-intercept
	float getYintercept (Point2D point);
	
	///@Purpose: add l1 line to l2 line and return the sum
	///@Return:  line object.
	static Line2D<T> add ( Line2D<T> line1, Line2D<T> line2 );
 	///@Purpose: subtract line1 line from line2 line and return the difference
	///@Return:  new line object 
	static Line2D<T> subtract ( Line2D<T> line1, Line2D<T> line2 );
	
 	///----------------------------------------------------
	/// the following methods become:
	/// - Operators in C++ .
	///	- Normal methods in Java
	///----------------------------------------------------
 

	boolean equals   ( [IN] Line2D<T> other );
	/// you can ignore it in java version .. 
	/// in c++ version it will become != .
	boolean Notequal( [IN] Line2D<T> other );
};