I used the Cohen Sutherland method for this
Thanks Cohen Sutherland, and Wikipedia aswell as geeksforgeeks (demystifying Wikipedia)