#NEWLINE# def reflect( self , line ) : #NEWLINE# #INDENT# from sympy import atan , Point , Dummy , oo #NEWLINE# g = self #NEWLINE# l = line #NEWLINE# o = Point ( 0 , 0 ) #NEWLINE# if ( l . slope == 0 ) : #NEWLINE# #INDENT# y = l . args [ 0 ] . y #NEWLINE# if ( not y ) : #NEWLINE# #INDENT# return g . scale ( y = ( - 1 ) ) #NEWLINE# #UNINDENT# reps = [ ( p , p . translate ( y = ( 2 * ( y - p . y ) ) ) ) for p in g . atoms ( Point ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( l . slope == oo ) : #NEWLINE# #INDENT# x = l . args [ 0 ] . x #NEWLINE# if ( not x ) : #NEWLINE# #INDENT# return g . scale ( x = ( - 1 ) ) #NEWLINE# #UNINDENT# reps = [ ( p , p . translate ( x = ( 2 * ( x - p . x ) ) ) ) for p in g . atoms ( Point ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not hasattr ( g , 'reflect' ) ) and ( not all ( ( isinstance ( arg , Point ) for arg in g . args ) ) ) ) : #NEWLINE# #INDENT# raise NotImplementedError ( ( 'reflect undefined or non-Point args in %s' % g ) ) #NEWLINE# #UNINDENT# a = atan ( l . slope ) #NEWLINE# c = l . coefficients #NEWLINE# d = ( ( - c [ ( - 1 ) ] ) / c [ 1 ] ) #NEWLINE# ( x , y ) = ( Dummy ( ) , Dummy ( ) ) #NEWLINE# xf = Point ( x , y ) #NEWLINE# xf = xf . translate ( y = ( - d ) ) . rotate ( ( - a ) , o ) . scale ( y = ( - 1 ) ) . rotate ( a , o ) . translate ( y = d ) #NEWLINE# reps = [ ( p , xf . xreplace ( { #NEWLINE# #INDENT# x : p . x , #NEWLINE# x : p . y , #NEWLINE# #UNINDENT# } ) ) for p in g . atoms ( Point ) ] #NEWLINE# #UNINDENT# #UNINDENT# return g . xreplace ( dict ( reps ) )