<s> try : <EOL> import unittest2 as unittest <EOL> except : <EOL> import unittest <EOL> import numpy as np <EOL> from pyrr import quaternion <EOL> class test_quaternion ( unittest . TestCase ) : <EOL> def test_import ( self ) : <EOL> import pyrr <EOL> pyrr . quaternion <EOL> from pyrr import quaternion <EOL> def test_create ( self ) : <EOL> result = quaternion . create ( ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] , decimal = <NUM_LIT:5> ) <EOL> self . assertTrue ( result . dtype == np . float ) <EOL> def test_create_parameters ( self ) : <EOL> result = quaternion . create ( <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:1.0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , decimal = <NUM_LIT:5> ) <EOL> self . assertTrue ( result . dtype == np . float ) <EOL> def test_create_from_x_rotation ( self ) : <EOL> q = quaternion . create_from_x_rotation ( np . pi ) <EOL> self . assertTrue ( np . allclose ( q , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) ) <EOL> q = quaternion . create_from_x_rotation ( np . pi / <NUM_LIT> ) <EOL> self . assertTrue ( np . allclose ( q , [ np . sqrt ( <NUM_LIT:0.5> ) , <NUM_LIT:0.> , <NUM_LIT:0.> , np . sqrt ( <NUM_LIT:0.5> ) ] ) ) <EOL> q = quaternion . create_from_x_rotation ( - np . pi / <NUM_LIT> ) <EOL> self . assertTrue ( np . allclose ( q , [ - np . sqrt ( <NUM_LIT:0.5> ) , <NUM_LIT:0.> , <NUM_LIT:0.> , np . sqrt ( <NUM_LIT:0.5> ) ] ) ) <EOL> def test_create_from_y_rotation ( self ) : <EOL> q = quaternion . create_from_y_rotation ( np . pi ) <EOL> self . assertTrue ( np . allclose ( q , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) ) <EOL> q = quaternion . create_from_y_rotation ( np . pi / <NUM_LIT> ) <EOL> self . assertTrue ( np . allclose ( q , [ <NUM_LIT:0.> , np . sqrt ( <NUM_LIT:0.5> ) , <NUM_LIT:0.> , np . sqrt ( <NUM_LIT:0.5> ) ] ) ) <EOL> q = quaternion . create_from_y_rotation ( - np . pi / <NUM_LIT> ) <EOL> def test_create_from_z_rotation ( self ) : <EOL> q = quaternion . create_from_z_rotation ( np . pi ) <EOL> self . assertTrue ( np . allclose ( q , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) ) <EOL> q = quaternion . create_from_z_rotation ( np . pi / <NUM_LIT> ) <EOL> self . assertTrue ( np . allclose ( q , [ <NUM_LIT:0.> , <NUM_LIT:0.> , np . sqrt ( <NUM_LIT:0.5> ) , np . sqrt ( <NUM_LIT:0.5> ) ] ) ) <EOL> q = quaternion . create_from_z_rotation ( - np . pi / <NUM_LIT> ) <EOL> def test_create_from_axis_rotation ( self ) : <EOL> result = quaternion . create_from_axis_rotation ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , np . pi ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , decimal = <NUM_LIT:3> ) <EOL> self . assertTrue ( result . dtype == np . float ) <EOL> def test_create_from_axis_rotation_non_normalised ( self ) : <EOL> result = quaternion . create_from_axis_rotation ( [ <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> ] , np . pi ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , decimal = <NUM_LIT:3> ) <EOL> self . assertTrue ( result . dtype == np . float ) <EOL> def test_create_from_matrix_unit ( self ) : <EOL> result = quaternion . create_from_matrix ( np . eye ( <NUM_LIT:3> ) ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] , decimal = <NUM_LIT:5> ) <EOL> self . assertTrue ( result . dtype == np . float ) <EOL> def test_create_from_matrix_x ( self ) : <EOL> result = quaternion . create_from_matrix ( [ <EOL> [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT:0.> , - <NUM_LIT:1.> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT:0.> , <NUM_LIT:0.> , - <NUM_LIT:1.> ] , <EOL> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , decimal = <NUM_LIT:5> ) <EOL> self . assertTrue ( result . dtype == np . float ) <EOL> def test_create_from_matrix_y ( self ) : <EOL> result = quaternion . create_from_matrix ( [ <EOL> [ - <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT:0.> , <NUM_LIT:0.> , - <NUM_LIT:1.> ] , <EOL> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , decimal = <NUM_LIT:5> ) <EOL> self . assertTrue ( result . dtype == np . float ) <EOL> def test_create_from_matrix_z ( self ) : <EOL> result = quaternion . create_from_matrix ( [ <EOL> [ - <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT:0.> , - <NUM_LIT:1.> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] , <EOL> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] , decimal = <NUM_LIT:5> ) <EOL> self . assertTrue ( result . dtype == np . float ) <EOL> @ unittest . skip ( '<STR_LIT>' ) <EOL> def test_create_from_eulers ( self ) : <EOL> pass <EOL> @ unittest . skip ( '<STR_LIT>' ) <EOL> def test_create_from_inverse_of_eulers ( self ) : <EOL> pass <EOL> def test_cross ( self ) : <EOL> q1 = quaternion . create_from_x_rotation ( np . pi / <NUM_LIT> ) <EOL> q2 = quaternion . create_from_x_rotation ( - np . pi / <NUM_LIT> ) <EOL> result = quaternion . cross ( q1 , q2 ) <EOL> np . testing . assert_almost_equal ( result , quaternion . create ( ) , decimal = <NUM_LIT:5> ) <EOL> def test_is_zero_length ( self ) : <EOL> result = quaternion . is_zero_length ( [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) <EOL> self . assertFalse ( result ) <EOL> def test_is_zero_length_zero ( self ) : <EOL> result = quaternion . is_zero_length ( [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) <EOL> self . assertTrue ( result ) <EOL> def test_is_non_zero_length ( self ) : <EOL> result = quaternion . is_non_zero_length ( [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) <EOL> self . assertTrue ( result ) <EOL> def test_is_non_zero_length_zero ( self ) : <EOL> result = quaternion . is_non_zero_length ( [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) <EOL> self . assertFalse ( result ) <EOL> def test_squared_length_identity ( self ) : <EOL> result = quaternion . squared_length ( [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) <EOL> np . testing . assert_almost_equal ( result , <NUM_LIT:1.> , decimal = <NUM_LIT:5> ) <EOL> def test_squared_length ( self ) : <EOL> result = quaternion . squared_length ( [ <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> ] ) <EOL> np . testing . assert_almost_equal ( result , <NUM_LIT> , decimal = <NUM_LIT:5> ) <EOL> def test_squared_length_batch ( self ) : <EOL> result = quaternion . squared_length ( [ <EOL> [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] , <EOL> [ <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> ] , <EOL> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:1.> , <NUM_LIT> ] , decimal = <NUM_LIT:5> ) <EOL> def test_length_identity ( self ) : <EOL> result = quaternion . length ( [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) <EOL> np . testing . assert_almost_equal ( result , <NUM_LIT:1.> , decimal = <NUM_LIT:5> ) <EOL> def test_length ( self ) : <EOL> result = quaternion . length ( [ <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> ] ) <EOL> np . testing . assert_almost_equal ( result , <NUM_LIT> , decimal = <NUM_LIT:5> ) <EOL> def test_length_batch ( self ) : <EOL> result = quaternion . length ( [ <EOL> [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] , <EOL> [ <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> , <NUM_LIT:1.> ] , <EOL> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:1.> , <NUM_LIT> ] , decimal = <NUM_LIT:5> ) <EOL> def test_normalise_identity ( self ) : <EOL> result = quaternion . normalise ( [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] , decimal = <NUM_LIT:5> ) <EOL> def test_normalise_non_identity ( self ) : <EOL> result = quaternion . normalise ( [ <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:1.> / np . sqrt ( <NUM_LIT> ) , np . sqrt ( <NUM_LIT> / <NUM_LIT> ) , np . sqrt ( <NUM_LIT> / <NUM_LIT> ) , <NUM_LIT> * np . sqrt ( <NUM_LIT> / <NUM_LIT> ) ] , decimal = <NUM_LIT:5> ) <EOL> def test_normalise_batch ( self ) : <EOL> result = quaternion . normalise ( [ <EOL> [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] , <EOL> [ <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , <EOL> ] ) <EOL> expected = [ <EOL> [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] , <EOL> [ <NUM_LIT:1.> / np . sqrt ( <NUM_LIT> ) , np . sqrt ( <NUM_LIT> / <NUM_LIT> ) , np . sqrt ( <NUM_LIT> / <NUM_LIT> ) , <NUM_LIT> * np . sqrt ( <NUM_LIT> / <NUM_LIT> ) ] , <EOL> ] <EOL> np . testing . assert_almost_equal ( result , expected , decimal = <NUM_LIT:5> ) <EOL> def test_rotation_angle ( self ) : <EOL> result = quaternion . rotation_angle ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> np . testing . assert_almost_equal ( result , np . pi , decimal = <NUM_LIT:5> ) <EOL> def test_rotation_axis ( self ) : <EOL> result = quaternion . rotation_axis ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] , decimal = <NUM_LIT:5> ) <EOL> def test_dot_adjacent ( self ) : <EOL> result = quaternion . dot ( [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) <EOL> np . testing . assert_almost_equal ( result , <NUM_LIT:0.0> , decimal = <NUM_LIT:5> ) <EOL> def test_dot_parallel ( self ) : <EOL> result = quaternion . dot ( [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) <EOL> np . testing . assert_almost_equal ( result , <NUM_LIT:1.0> , decimal = <NUM_LIT:5> ) <EOL> def test_dot_angle ( self ) : <EOL> result = quaternion . dot ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , [ <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) <EOL> np . testing . assert_almost_equal ( result , <NUM_LIT> , decimal = <NUM_LIT:5> ) <EOL> def test_dot_batch ( self ) : <EOL> result = quaternion . dot ( [ <EOL> [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.> , <NUM_LIT:0.> ] <EOL> ] , [ <EOL> [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , <EOL> [ <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0.> , <NUM_LIT:0.> ] <EOL> ] ) <EOL> expected = [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT> ] <EOL> np . testing . assert_almost_equal ( result , expected , decimal = <NUM_LIT:5> ) <EOL> def test_conjugate ( self ) : <EOL> result = quaternion . conjugate ( [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] , decimal = <NUM_LIT:5> ) <EOL> def test_conjugate_rotation ( self ) : <EOL> result = quaternion . conjugate ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> np . testing . assert_almost_equal ( result , [ - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT> ] , decimal = <NUM_LIT:5> ) <EOL> @ unittest . skip ( '<STR_LIT>' ) <EOL> def test_power ( self ) : <EOL> pass <EOL> def test_inverse ( self ) : <EOL> result = quaternion . inverse ( [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] , decimal = <NUM_LIT:5> ) <EOL> def test_inverse_rotation ( self ) : <EOL> result = quaternion . inverse ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> np . testing . assert_almost_equal ( result , [ - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> , <NUM_LIT> ] , decimal = <NUM_LIT:5> ) <EOL> def test_inverse_non_unit ( self ) : <EOL> q = [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] <EOL> result = quaternion . inverse ( q ) <EOL> expected = quaternion . conjugate ( q ) / quaternion . length ( q ) <EOL> np . testing . assert_almost_equal ( result , expected , decimal = <NUM_LIT:5> ) <EOL> def test_negate_unit ( self ) : <EOL> result = quaternion . negate ( [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , - <NUM_LIT:1.> ] , decimal = <NUM_LIT:5> ) <EOL> def test_negate ( self ) : <EOL> result = quaternion . negate ( [ <NUM_LIT:1.> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) <EOL> np . testing . assert_almost_equal ( result , [ - <NUM_LIT:1.> , - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ] , decimal = <NUM_LIT:5> ) <EOL> def test_apply_to_vector_unit_x ( self ) : <EOL> result = quaternion . apply_to_vector ( [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) <EOL> np . testing . assert_almost_equal ( result , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] , decimal = <NUM_LIT:5> ) <EOL> def test_apply_to_vector_x ( self ) : <EOL> q = quaternion . create_from_x_rotation ( np . pi ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:0.> , - <NUM_LIT:1.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:0.> , - <NUM_LIT:1.> ] ) ) <EOL> q = quaternion . create_from_x_rotation ( np . pi / <NUM_LIT> ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) , [ <NUM_LIT:0.> , - <NUM_LIT:1.> , <NUM_LIT:0.> ] ) ) <EOL> q = quaternion . create_from_x_rotation ( - np . pi / <NUM_LIT> ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:0.> , - <NUM_LIT:1.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) ) <EOL> def test_apply_to_vector_y ( self ) : <EOL> q = quaternion . create_from_y_rotation ( np . pi ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) , [ - <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:0.> , - <NUM_LIT:1.> ] ) ) <EOL> q = quaternion . create_from_y_rotation ( np . pi / <NUM_LIT> ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:0.> , - <NUM_LIT:1.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) ) <EOL> q = quaternion . create_from_y_rotation ( - np . pi / <NUM_LIT> ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) , [ - <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) ) <EOL> def test_apply_to_vector_z ( self ) : <EOL> q = quaternion . create_from_z_rotation ( np . pi ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) , [ - <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:0.> , - <NUM_LIT:1.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) ) <EOL> q = quaternion . create_from_z_rotation ( np . pi / <NUM_LIT> ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) , [ - <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) ) <EOL> q = quaternion . create_from_z_rotation ( - np . pi / <NUM_LIT> ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:0.> , - <NUM_LIT:1.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ] ) , [ <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ] ) ) <EOL> self . assertTrue ( np . allclose ( quaternion . apply_to_vector ( q , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) , [ <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ] ) ) <EOL> def test_identity ( self ) : <EOL> i = quaternion . create ( <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> ) <EOL> j = quaternion . create ( <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> , <NUM_LIT:0.> ) <EOL> k = quaternion . create ( <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> , <NUM_LIT:0.> ) <EOL> one = quaternion . create ( <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:0.> , <NUM_LIT:1.> ) <EOL> i1 = quaternion . cross ( i , one ) <EOL> j1 = quaternion . cross ( j , one ) <EOL> k1 = quaternion . cross ( k , one ) <EOL> _1i = quaternion . cross ( one , i ) <EOL> _1j = quaternion . cross ( one , j ) <EOL> _1k = quaternion . cross ( one , k ) <EOL> self . assertTrue ( np . allclose ( i1 , _1i , i ) ) <EOL> self . assertTrue ( np . allclose ( j1 , _1j , j ) ) <EOL> self . assertTrue ( np . allclose ( k1 , _1k , k ) ) <EOL> ii = quaternion . cross ( i , i ) <EOL> kk = quaternion . cross ( k , k ) <EOL> jj = quaternion . cross ( j , j ) <EOL> ijk = quaternion . cross ( quaternion . cross ( i , j ) , k ) <EOL> self . assertTrue ( np . allclose ( ii , - one ) ) <EOL> self . assertTrue ( np . allclose ( jj , - one ) ) <EOL> self . assertTrue ( np . allclose ( kk , - one ) ) <EOL> self . assertTrue ( np . allclose ( ijk , - one ) ) <EOL> ij = quaternion . cross ( i , j ) <EOL> ji = quaternion . cross ( j , i ) <EOL> jk = quaternion . cross ( j , k ) <EOL> kj = quaternion . cross ( k , j ) <EOL> ki = quaternion . cross ( k , i ) <EOL> ik = quaternion . cross ( i , k ) <EOL> self . assertTrue ( np . allclose ( ij , k ) ) <EOL> self . assertTrue ( np . allclose ( ji , - k ) ) <EOL> self . assertTrue ( np . allclose ( jk , i ) ) <EOL> self . assertTrue ( np . allclose ( kj , - i ) ) <EOL> self . assertTrue ( np . allclose ( ki , j ) ) <EOL> self . assertTrue ( np . allclose ( ik , - j ) ) <EOL> ijkk = quaternion . cross ( quaternion . cross ( ij , k ) , k ) <EOL> ijk2 = quaternion . cross ( ij , quaternion . cross ( k , k ) ) <EOL> ij_m1 = quaternion . cross ( ij , - one ) <EOL> self . assertTrue ( np . allclose ( ijkk , ijk2 ) ) <EOL> self . assertTrue ( np . allclose ( ijk2 , ij_m1 ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
