# ars / tests / utils_mathematical.py

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49``` ```import numpy import ars.utils.mathematical as mut def _vector_diff_length(v1, v2): return mut.length3(mut.sub3(v1, v2)) def test_np_matrix_to_tuple(): arr = numpy.array(((2, 2), (2, -2))) print(mut.np_matrix_to_tuple(arr)) def test_matrix_as_tuple(): print(mut.matrix_as_tuple(((1, 2), (3, 4)))) def test_matrix_multiply(): print (mut.matrix_multiply(((2,),(1,)), ((1,0,0,0,2,0,0,0,1), ))) print (mut.matrix_multiply(((2,0,0),(0,1,0),(0,0,1)), ((1,0,0),(0,2,0),(0,0,1)))) print (mut.matrix_multiply(((2,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1)), ((1,0,0,0),(0,2,0,0),(0,0,1,0),(0,0,0,1)))) def test_calc_acceleration(): print('%s, %s' % (0.0, mut.calc_acceleration(0.01, (15,-1.5,84), (15,-1.5,84)))) print('%s, %s' % (100.0, mut.calc_acceleration(0.01, (0,0,1), (0,0,2)))) print('%s, %s' % (-100.0, mut.calc_acceleration(0.01, (0,0,2), (0,0,1)))) print('%s, %s' % (141.421, mut.calc_acceleration(0.01, (0,1,0), (0,0,1)))) def test_XYZ_axes_for_orthogonality(): from ars.constants import X_AXIS, Y_AXIS, Z_AXIS X = X_AXIS Y = Y_AXIS Z = Z_AXIS print(_vector_diff_length(mut.cross_product(X, Y), Z)) print(_vector_diff_length(mut.cross_product(Z, X), Y)) print(_vector_diff_length(mut.cross_product(Y, Z), X)) if __name__ == "__main__": test_np_matrix_to_tuple() test_matrix_as_tuple() test_matrix_multiply() test_XYZ_axes_for_orthogonality() test_calc_acceleration() ```