#NEWLINE# def axis_changed( old , new , pos , points ) : #NEWLINE# #INDENT# 'The function takes 4 arguments, the old and the new axis, the\n    position and points. All arguments should be given as a numpy\n    array, The first 3 can also be given in form of a tuple. The\n    function rotates all the points so that they become aligned with\n    the new axis' #NEWLINE# o = ( old / float ( sqrt ( numpy . inner ( old , old ) ) ) ) #NEWLINE# n = ( new / sqrt ( numpy . inner ( new , new ) ) ) #NEWLINE# dpdt = numpy . dot ( o , n ) #NEWLINE# if ( abs ( ( abs ( dpdt ) - 1.0 ) ) < 1e-10 ) : #NEWLINE# #INDENT# if ( dpdt < 0 ) : #NEWLINE# #INDENT# diff = ( - pos ) #NEWLINE# points = translate_points ( diff , points ) #NEWLINE# points [ : ] = ( - points ) #NEWLINE# diff = pos #NEWLINE# points = translate_points ( diff , points ) #NEWLINE# return points #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return points #NEWLINE# #UNINDENT# #UNINDENT# alpha = acos ( dpdt ) #NEWLINE# raxis = numpy . cross ( o , n ) #NEWLINE# data = _create_rotation_matrix ( raxis , ( ( 180.0 * alpha ) / pi ) ) #NEWLINE# if numpy . allclose ( pos , 0.0 ) : #NEWLINE# #INDENT# points [ : ] = numpy . dot ( points , data . T ) #NEWLINE# return points #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# diff = ( - pos ) #NEWLINE# points = translate_points ( diff , points ) #NEWLINE# points [ : ] = numpy . dot ( points , data . T ) #NEWLINE# diff = pos #NEWLINE# points = translate_points ( diff , points ) #NEWLINE# return new