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

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