title: Clipping line to triangle c++
body: <p>In clipping algorithms there are many techniques such as Cohen–Sutherland,Cyrus–Beck algorithms for 2D line clipping also, there are many others for Circle and polygon. but I'm looking for such a way to clip line to a triangle window in c++ like as explained in image bellow : 
  <img src="https://i.stack.imgur.com/6QPIa.png" alt="enter image description here">    </p>
  
  <p>So I have three cases first one is that the line is inside the triangle which must be drawn, second case is out side the triangle which must not be drawn, third case the line has an end point inside the triangle and second outside which needs to be clipped to the triangle border, So what is a best way to do this with respect to performance of processing?!     </p>