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

	line2di* IrrCore_Line2di_new()
	{
		return new line2di();
	}
	
	line2di* IrrCore_Line2di_newFromVals(s32 xa,s32 ya,s32 xb,s32 yb)
	{
		return new line2di(xa,ya,xb,yb);
	}
	
	line2di* IrrCore_Line2di_newFromVects(vector2di* start,vector2di* end)
	{
		return new line2di(*start,*end);
	}
	
	line2di* IrrCore_Line2di_newFromLine(line2di* other)
	{
		return new line2di(*other);
	}
	
	void IrrCore_Line2di_del(line2di* del)
	{
		if (del)
			delete del;
			
		del=0;
	}
	
	void IrrCore_Line2di_setLineFromVals(line2di* line,s32 xa,s32 ya,s32 xb,s32 yb)
	{
		if (line)
			line->setLine(xa,ya,xb,yb);
	}
	
	void IrrCore_Line2di_setLineFromVects(line2di* line,vector2di* start,vector2di* end)
	{
		if (line)
			line->setLine(*start,*end);
	}
	
	void IrrCore_Line2di_setLineFromLine(line2di* line,line2di* other)
	{
		if (line)
			line->setLine(*other);
	}
	
	f64 IrrCore_Line2di_getLength(line2di* line)
	{
		f64 retval=0.0f;
		if (line)
			retval=line->getLength();
		
		return retval;
	}
	
	vector2di* IrrCore_Line2di_getVector(line2di* line)
	{
		vector2di* retval=0;
		if (line)
			retval=new vector2di(line->getVector());
		
		return retval;
	}
	
	vector2di* IrrCore_Line2di_getUnitVector(line2di* line)
	{
		vector2di* retval=0;
		if (line)
			retval=new vector2di(line->getUnitVector());
		
		return retval;
	}
	
	line2di* IrrCore_Line2di_Plus(line2di* line,vector2di* point)
	{
		line2di* retval=0;
		
		if (line)
			retval=new line2di(*line + *point);
		
		return retval;
	}
	
	line2di* IrrCore_Line2di_Minus(line2di* line,vector2di* point)
	{
		line2di* retval=0;
		
		if (line)
			retval=new line2di(*line - *point);
		
		return retval;
	}
	
	void IrrCore_Line2di_PlusEq(line2di* line,vector2di* point)
	{
		if (line)
			*line+=*point;
	}
	
	void IrrCore_Line2di_MinusEq(line2di* line,vector2di* point)
	{
		if (line)
			*line-=*point;
	}
	
	bool IrrCore_Line2di_EqEq(line2di* line,line2di* line2)
	{
		bool retval=false;
		
		if (line)
			retval=(*line==*line2);
			
		return retval;
	}
	
	bool IrrCore_Line2di_NotEq(line2di* line,line2di* line2)
	{
		bool retval=true;
		
		if (line)
			retval=(*line!=*line2);
			
		return retval;
	}
	
	
	f64 IrrCore_Line2di_getAngleWith(line2di* line,line2di* l)
	{
		f64 retval=0.0f;
		
		if (line) 
			retval=line->getAngleWith(*l);
		
		return retval;
	}
	
	bool IrrCore_Line2di_intersectWith(line2di* line,line2di* line2,vector2di* out)
	{
		// intersectWith had issues due to getIntersectionOfLines() and isPointBetweenPoints() missing
		bool retval=false;
		
		if (line)
			retval=line->intersectWith(*line2,*out);
		
		return retval;
	}
	
	vector2di* IrrCore_Line2di_getStart(line2di* line)
	{
		vector2di* retval=0;
		if (line)
			retval=&line->start;
		return retval;
	}
	
	vector2di* IrrCore_Line2di_getEnd(line2di* line)
	{
		vector2di* retval=0;
		if (line)
			retval=&line->end;
		return retval;
	}

	s32 IrrCore_Line2di_getLengthSQ(line2di* line)
	{
		if (line)
			return line->getLengthSQ();
		else return 0.0;
	}
	
	// must delete
	vector2di* IrrCore_Line2di_getMiddle(line2di* line)
	{
		if (line)
			return new vector2di(line->getMiddle());
		else return 0;
	}
	
	s32 IrrCore_Line2di_getPointOrientation(line2di* line,const vector2di& point)
	{
		if (line)
			return line->getPointOrientation(point);
		else return 0.0;
	}
	
	bool IrrCore_Line2di_isPointOnLine(line2di* line,const vector2di& point)
	{
		if (line)
			return line->isPointOnLine(point);
		else return false;
	}
	
	bool IrrCore_Line2di_isPointBetweenStartAndEnd(line2di* line,const vector2di& point)
	{
		if (line)
			return line->isPointBetweenStartAndEnd(point);
		else return false;
	}

	// must delete
	vector2di* IrrCore_Line2di_getClosestPoint(line2di* line,const vector2di& point)
	{
		if (line)
			return new vector2di(line->getClosestPoint(point));
		else return 0;
	}
}