// ------------------------------------------------------------------------------------
// irr::core::line2df wrappers
// ------------------------------------------------------------------------------------
extern "C" 
{

	line2df* IrrCore_Line2df_new()
	{
		return new line2df();
	}
	
	line2df* IrrCore_Line2df_newFromVals(f32 xa,f32 ya,f32 xb,f32 yb)
	{
		return new line2df(xa,ya,xb,yb);
	}
	
	line2df* IrrCore_Line2df_newFromVects(vector2df* start,vector2df* end)
	{
		return new line2df(*start,*end);
	}
	
	line2df* IrrCore_Line2df_newFromLine(line2df* other)
	{
		return new line2df(*other);
	}
	
	void IrrCore_Line2df_del(line2df* del)
	{
		if (del)
			delete del;
			
		del=0;
	}
	
	void IrrCore_Line2df_setLineFromVals(line2df* line,f32 xa,f32 ya,f32 xb,f32 yb)
	{
		if (line)
			line->setLine(xa,ya,xb,yb);
	}
	
	void IrrCore_Line2df_setLineFromVects(line2df* line,vector2df* start,vector2df* end)
	{
		if (line)
			line->setLine(*start,*end);
	}
	
	void IrrCore_Line2df_setLineFromLine(line2df* line,line2df* other)
	{
		if (line)
			line->setLine(*other);
	}
	
	f64 IrrCore_Line2df_getLength(line2df* line)
	{
		f64 retval=0.0f;
		if (line)
			retval=line->getLength();
		
		return retval;
	}
	
	vector2df* IrrCore_Line2df_getVector(line2df* line)
	{
		vector2df* retval=0;
		if (line)
			retval=new vector2df(line->getVector());
		
		return retval;
	}
	
	vector2df* IrrCore_Line2df_getUnitVector(line2df* line)
	{
		vector2df* retval=0;
		if (line)
			retval=new vector2df(line->getUnitVector());
		
		return retval;
	}
	
	line2df* IrrCore_Line2df_Plus(line2df* line,vector2df* point)
	{
		line2df* retval=0;
		
		if (line)
			retval=new line2df(*line + *point);
		
		return retval;
	}
	
	line2df* IrrCore_Line2df_Minus(line2df* line,vector2df* point)
	{
		line2df* retval=0;
		
		if (line)
			retval=new line2df(*line - *point);
		
		return retval;
	}
	
	void IrrCore_Line2df_PlusEq(line2df* line,vector2df* point)
	{
		if (line)
			*line+=*point;
	}
	
	void IrrCore_Line2df_MinusEq(line2df* line,vector2df* point)
	{
		if (line)
			*line-=*point;
	}
	
	bool IrrCore_Line2df_EqEq(line2df* line,line2df* line2)
	{
		bool retval=false;
		
		if (line)
			retval=(*line==*line2);
			
		return retval;
	}
	
	bool IrrCore_Line2df_NotEq(line2df* line,line2df* line2)
	{
		bool retval=true;
		
		if (line)
			retval=(*line!=*line2);
			
		return retval;
	}
	
	
	f64 IrrCore_Line2df_getAngleWith(line2df* line,line2df* l)
	{
		f64 retval=0.0f;
		
		if (line) 
			retval=line->getAngleWith(*l);
		
		return retval;
	}
	
	bool IrrCore_Line2df_intersectWith(line2df* line,line2df* line2,vector2df* out)
	{
		bool retval=false;
		
		if (line)
			retval=line->intersectWith(*line2,*out);
		
		return retval;
	}
	
	vector2df* IrrCore_Line2df_getStart(line2df* line)
	{
		vector2df* retval=0;
		if (line)
			retval=&line->start;
		return retval;
	}
	
	vector2df* IrrCore_Line2df_getEnd(line2df* line)
	{
		vector2df* retval=0;
		if (line)
			retval=&line->end;
		return retval;
	}

	f32 IrrCore_Line2df_getLengthSQ(line2df* line)
	{
		if (line)
			return line->getLengthSQ();
		else return 0.0;
	}
	
	// must delete
	vector2df* IrrCore_Line2df_getMiddle(line2df* line)
	{
		if (line)
			return new vector2df(line->getMiddle());
		else return 0;
	}
	
	f32 IrrCore_Line2df_getPointOrientation(line2df* line,const vector2df& point)
	{
		if (line)
			return line->getPointOrientation(point);
		else return 0.0;
	}
	
	bool IrrCore_Line2df_isPointOnLine(line2df* line,const vector2df& point)
	{
		if (line)
			return line->isPointOnLine(point);
		else return false;
	}
	
	bool IrrCore_Line2df_isPointBetweenStartAndEnd(line2df* line,const vector2df& point)
	{
		if (line)
			return line->isPointBetweenStartAndEnd(point);
		else return false;
	}

	// must delete
	vector2df* IrrCore_Line2df_getClosestPoint(line2df* line,const vector2df& point)
	{
		if (line)
			return new vector2df(line->getClosestPoint(point));
		else return 0;
	}
}