#NEWLINE# def allSplineYGivenX( self , vts ) : #NEWLINE# #INDENT# s = self . s #NEWLINE# c = self . c #NEWLINE# e = self . e #NEWLINE# a = ( ( s [ 0 ] - ( 2 * c [ 0 ] ) ) + e [ 0 ] ) #NEWLINE# b = ( ( 2 * c [ 0 ] ) - ( 2 * s [ 0 ] ) ) #NEWLINE# c = ( s [ 0 ] - vts [ : , 0 ] ) #NEWLINE# if ( a == 0 ) : #NEWLINE# #INDENT# t = nan #NEWLINE# if ( b == 0 ) : #NEWLINE# #INDENT# t = ( ( - 1 ) * ones ( vts . shape [ 0 ] ) ) #NEWLINE# isSSmaller = ( s [ 1 ] < c [ 1 ] ) #NEWLINE# isAtX = ( vts [ : , 0 ] == s [ 0 ] ) #NEWLINE# t [ isAtX ] = ( ( t [ isAtX ] + ( 1 * isSSmaller ) ) + ( 2 * ( ~ isSSmaller ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# t = ( ( ( - 1.0 ) * c ) / b ) #NEWLINE# #UNINDENT# closest_ys = ( Inf * ones ( ( vts . shape [ 0 ] , 2 ) ) ) #NEWLINE# isValid = ( ( 0 <= t ) * ( t <= 1 ) ) #NEWLINE# y_ts = ( ( ( ( ( 1 - t ) ** 2 ) * s [ 1 ] ) + ( ( ( 2 * ( 1 - t ) ) * t ) * c [ 1 ] ) ) + ( ( t * t ) * e [ 1 ] ) ) #NEWLINE# isClosest = ( ( ( x_ts - vts [ : , 1 ] ) > 0 ) * isValid ) #NEWLINE# for i in range ( closest_xs . shape [ 1 ] ) : #NEWLINE# #INDENT# closest_xs [ ( isClosest , i ) ] = x_ts [ isClosest ] #NEWLINE# #UNINDENT# return closest_xs #NEWLINE# #UNINDENT# t1 = ( ( ( - b ) + ( ( ( b * b ) - ( ( 4 * a ) * c ) ) ** 0.5 ) ) / ( 2 * a ) ) #NEWLINE# t2 = ( ( ( - b ) - ( ( ( b * b ) - ( ( 4 * a ) * c ) ) ** 0.5 ) ) / ( 2 * a ) ) #NEWLINE# closest_ys = ( Inf * ones ( ( vts . shape [ 0 ] , 2 ) ) ) #NEWLINE# isValid1 = ( ( 0 <= t1 ) * ( t1 <= 1 ) ) #NEWLINE# isValid2 = ( ( 0 <= t2 ) * ( t2 <= 1 ) ) #NEWLINE# y_t1 = ( ( ( ( ( 1 - t1 ) ** 2 ) * s [ 1 ] ) + ( ( ( 2 * ( 1 - t1 ) ) * t1 ) * c [ 1 ] ) ) + ( ( t1 * t1 ) * e [ 1 ] ) ) #NEWLINE# y_t2 = ( ( ( ( ( 1 - t2 ) ** 2 ) * s [ 1 ] ) + ( ( ( 2 * ( 1 - t2 ) ) * isSSmaller ) * c [ 1 ] ) ) + ( ( t2 * t2 ) * e [ 1 ] ) ) #NEWLINE# closest_ys [ ( isValid1 , 0 ) ] = y_t1 [ isValid1 ] #NEWLINE# closest_ys [ ( isValid2 , 1 ) ] = y_t2 [ isValid2 ] #NEWLINE# return closest_ys