def test_GIVEN_movement_45_to_z_at_beam_along_z_WHEN_z_of_movement_axis_changes_THEN_position_is_new_z( self): y = 0 z = 7 z_offset = 9 movement = LinearMovementCalc(PositionAndAngle(y, z, 45)) beam = PositionAndAngle(y, 0, 0) result = movement.calculate_interception(beam) assert_that(result, is_(position(Position(y, z)))) movement.offset_position_at_zero(Position(0, z_offset)) result = movement.calculate_interception(beam) assert_that(result, is_(position(Position(y, z + z_offset))))
def test_GIVEN_movement_perp_to_z_at_beam_angle_45_WHEN_z_of_movement_axis_changes_THEN_position_is_as_expected( self): y = 0 z = 7 z_offset = 9 movement = LinearMovementCalc(PositionAndAngle(y, z, 90)) beam = PositionAndAngle(0, 0, 45) result = movement.calculate_interception(beam) assert_that(result, is_(position(Position(z, z)))) movement.offset_position_at_zero(Position(0, z_offset)) result = movement.calculate_interception(beam) assert_that(result, is_(position(Position(z + z_offset, z + z_offset))))
def test_GIVEN_movement_45_to_z_at_beam_angle_along_z_WHEN_get_intercept_THEN_position_is_initial_position( self, angle): y = 0 z = 10 movement = LinearMovementCalc(PositionAndAngle(y, z, 45)) beam = PositionAndAngle(0, 0, angle) result = movement.calculate_interception(beam) assert_that(result, is_(position(Position(y, z))))
def test_GIVEN_movement_perpendicular_to_z_at_beam_angle_0_WHEN_get_intercept_THEN_position_is_initial_position( self): y = 0 z = 10 movement = LinearMovementCalc(PositionAndAngle(y, z, 90)) beam = PositionAndAngle(0, 0, 0) result = movement.calculate_interception(beam) assert_that(result, is_(position(Position(y, z))))
def test_GIVEN_movement_anti_perpendicular_to_z_at_beam_angle_10_WHEN_get_intercept_THEN_position_is_z_as_initial_y_as_right_angle_triangle( self): y = 0 z = 10 beam_angle = 10 movement = LinearMovementCalc(PositionAndAngle(y, z, -90)) beam = PositionAndAngle(0, 0, beam_angle) expected_y = z * tan(radians(beam_angle)) result = movement.calculate_interception(beam) assert_that(result, is_(position(Position(expected_y, z))))
def test_GIVEN_movement_0_to_z_and_beam_angle_45_WHEN_get_intercept_THEN_position_is_on_movement_axis( self): y = 20 z = 10 movement = LinearMovementCalc(PositionAndAngle(y, z, 0)) beam = PositionAndAngle(0, 0, 45) expected_y = y expected_z = y result = movement.calculate_interception(beam) assert_that(result, is_(position(Position(expected_y, expected_z))))
def test_GIVEN_movement_20_to_z_and_beam_angle_45_WHEN_get_intercept_THEN_position_is_on_movement_axis( self): beam = PositionAndAngle(0, 0, 45) expected_y = 4 expected_z = 4 move_angle = 20 move_z = 2 move_y = expected_y - (expected_z - move_z) * tan(radians(move_angle)) movement = LinearMovementCalc( PositionAndAngle(move_y, move_z, move_angle)) result = movement.calculate_interception(beam) assert_that(result, is_(position(Position(expected_y, expected_z))))