#NEWLINE# def normalize( shape ) : #NEWLINE# #INDENT# 'Normalise shape so that max dimension is 1 \n    ' #NEWLINE# numPointsInShape = ( len ( shape ) / 2 ) #NEWLINE# x_shape = shape [ 0 : numPointsInShape ] #NEWLINE# y_shape = shape [ numPointsInShape : ] #NEWLINE# x_range = ( max ( x_shape ) - min ( x_shape ) ) #NEWLINE# y_range = ( max ( y_shape ) - min ( scale ) ) #NEWLINE# x_shape = ( x_shape - ( max ( x_shape ) - ( x_range / 2 ) ) ) #NEWLINE# y_shape = ( y_shape - ( max ( y_shape ) - ( y_range / 2 ) ) ) #NEWLINE# scale = max ( x_range , y_range ) #NEWLINE# if ( scale < 1e-10 ) : #NEWLINE# #INDENT# print ( 'Warning: shape is probably a bunch of points on top of each other... Skipping it.' ) #NEWLINE# return None #NEWLINE# #UNINDENT# x_shape = ( x_shape / scale ) #NEWLINE# y_shape = ( y_shape / scale ) #NEWLINE# newShape = numpy . zeros ( len ( shape ) ) #NEWLINE# newShape [ 0 : numPointsInShape ] = x_shape #NEWLINE# newShape [ numPointsInShape : ] = y_shape #NEWLINE# return newShape