def getYIntersectionIfExists(beginComplex, endComplex, x):
 if ((x > beginComplex.real) == (x > endComplex.real)):
  return None
 endMinusBeginComplex = (endComplex - beginComplex)
 return ((((x - beginComplex.real) / endMinusBeginComplex.real) * endMinusBeginComplex.imag) + beginComplex.imag)

def getYIntersectionIfExists ( beginComplex , endComplex , x ) : if ( ( x > beginComplex . real ) == ( x > endComplex . real ) ) : return None endMinusBeginComplex = ( endComplex - beginComplex ) return ( ( ( ( x - beginComplex . real ) / endMinusBeginComplex . real ) * endMinusBeginComplex . imag ) + beginComplex . imag )
get the y intersection if it exists .