AddMaterials.View.Controls.FillPatternViewerControlWpf.LineIntersectsLine C# (CSharp) Method

LineIntersectsLine() private method

private LineIntersectsLine ( System l1p1, System l1p2, System l2p1, System l2p2 ) : bool
l1p1 System
l1p2 System
l2p1 System
l2p2 System
return bool
        private bool LineIntersectsLine( 
            System.Drawing.Point l1p1,
            System.Drawing.Point l1p2,
            System.Drawing.Point l2p1,
            System.Drawing.Point l2p2)
        {
            try
              {
            Int64 d = ( l1p2.X - l1p1.X ) * ( l2p2.Y - l2p1.Y ) - ( l1p2.Y - l1p1.Y ) * ( l2p2.X - l2p1.X );
            if( d == 0 ) return false;

            Int64 q = ( l1p1.Y - l2p1.Y ) * ( l2p2.X - l2p1.X ) - ( l1p1.X - l2p1.X ) * ( l2p2.Y - l2p1.Y );
            Int64 r = q / d;

            Int64 q1 = (Int64) ( l1p1.Y - l2p1.Y ) * (Int64) ( l1p2.X - l1p1.X );
            Int64 q2 = (Int64) ( l1p1.X - l2p1.X ) * (Int64) ( l1p2.Y - l1p1.Y );

            q = q1 - q2;
            Int64 s = q / d;

            if( r < 0 || r > 1 || s < 0 || s > 1 )
              return false;

            return true;
              }
              catch( OverflowException err )
              {
            Debug.Print( "----------------------------------" );
            Debug.Print( err.Message );
            Debug.Print( l1p1.ToString() );
            Debug.Print( l1p2.ToString() );
            Debug.Print( l2p1.ToString() );
            Debug.Print( l2p2.ToString() );
            return false;
              }
        }