diff --git a/README.md b/README.md index 0345e5c..ec96ec4 100644 --- a/README.md +++ b/README.md @@ -63,9 +63,7 @@ Run them by running `python setup.py test` (or `pytest`). ## Co-ordinate spaces sb-vision describes the locations of identified markers in either Cartesian or -spherical co-ordinate spaces. A "legacy polar" co-ordinate space exists for -backwards compatibility but is deprecated, undocumented and will be removed in -May 2018. +spherical co-ordinate spaces. ### Cartesian co-ordinates diff --git a/sb_vision/__init__.py b/sb_vision/__init__.py index 21b3492..692dba4 100644 --- a/sb_vision/__init__.py +++ b/sb_vision/__init__.py @@ -7,7 +7,7 @@ """ from .camera import Camera, FileCamera -from .coordinates import Cartesian, LegacyPolar, Spherical, cartesian_to_spherical +from .coordinates import Cartesian, Spherical, cartesian_to_spherical from .tokens import Token from .vision import Vision @@ -17,7 +17,6 @@ 'FileCamera', 'Token', 'Cartesian', - 'LegacyPolar', 'Spherical', 'cartesian_to_spherical', ] diff --git a/sb_vision/coordinates.py b/sb_vision/coordinates.py index 01b9154..17ef755 100644 --- a/sb_vision/coordinates.py +++ b/sb_vision/coordinates.py @@ -2,7 +2,6 @@ from typing import NamedTuple, Union -import numpy as np from numpy import arctan2, float64, linalg AnyFloat = Union[float, float64] @@ -30,13 +29,6 @@ def tolist(self): ('dist', AnyFloat), )) -LegacyPolar = NamedTuple('LegacyPolar', ( - ('polar_x', AnyFloat), - ('polar_y', AnyFloat), - ('dist', AnyFloat), -)) - - PixelCoordinate = NamedTuple('PixelCoordinate', [('x', AnyFloat), ('y', AnyFloat)]) @@ -48,16 +40,3 @@ def cartesian_to_spherical(cartesian: Cartesian) -> Spherical: rot_y=arctan2(x, z), dist=linalg.norm(cartesian), ) - - -def cartesian_to_legacy_polar(cartesian: Cartesian) -> LegacyPolar: - """ - Convert cartesian co-ordinate space to the legacy "polar" space. - - This is kept for compatibility only. - """ - cart_x, cart_y, cart_z = tuple(cartesian) - polar_dist = np.linalg.norm(cartesian) - polar_x = np.arctan2(cart_z, cart_x) - polar_y = np.arctan2(cart_z, cart_y) - return LegacyPolar(polar_x, polar_y, polar_dist) diff --git a/sb_vision/tokens.py b/sb_vision/tokens.py index f8b003c..b569013 100644 --- a/sb_vision/tokens.py +++ b/sb_vision/tokens.py @@ -4,11 +4,7 @@ import numpy as np -from .coordinates import ( - Cartesian, - cartesian_to_legacy_polar, - cartesian_to_spherical, -) +from .coordinates import Cartesian, cartesian_to_spherical from .find_3D_coords import ( PixelCoordinate, calculate_transforms, @@ -110,9 +106,6 @@ def update_3D_transforms( self.cartesian = translation # Polar co-ordinates in the 3D world, relative to the camera - self.polar = cartesian_to_legacy_polar(self.cartesian) - self.legacy_polar = cartesian_to_legacy_polar(self.cartesian) - self.spherical = cartesian_to_spherical(self.cartesian) def __repr__(self) -> str: diff --git a/tests/test_coordinates_from_file.py b/tests/test_coordinates_from_file.py index b5d7a37..a08d9e2 100644 --- a/tests/test_coordinates_from_file.py +++ b/tests/test_coordinates_from_file.py @@ -6,7 +6,7 @@ import pytest from pytest import approx -from sb_vision import Cartesian, FileCamera, LegacyPolar, Spherical, Vision +from sb_vision import Cartesian, FileCamera, Spherical, Vision # Ensure all distance values are within this tolerance # (as a percentage of the total distance) @@ -20,11 +20,6 @@ ( '1.0z-0.1x.jpg', Cartesian(x=-0.1, y=0, z=1), - LegacyPolar( - polar_x=1.6704649792860642, - polar_y=1.5707963267948966, - dist=1.004987562112089, - ), Spherical( rot_x=0, rot_y=math.atan(-0.1), # or -5.710593137499643 degrees @@ -34,11 +29,6 @@ ( '3.0z1.0x.jpg', Cartesian(x=1, y=0, z=3), - LegacyPolar( - polar_x=1.1922, - polar_y=1.6032, - dist=(1 + 9)**0.5, # or 3.1622776601683795 - ), Spherical( rot_x=0, rot_y=math.atan(1 / 3), # or 18.43494882296774 degrees @@ -49,10 +39,10 @@ @pytest.mark.parametrize( - "photo, expected_cartesian, expected_polar, expected_spherical", + "photo, expected_cartesian, expected_spherical", TEST_IMAGES, ) -def test_image_coordinates(photo, expected_cartesian, expected_polar, expected_spherical): +def test_image_coordinates(photo, expected_cartesian, expected_spherical): """Make sure that this particular file gives these particular tokens.""" camera = FileCamera(CALIBRATIONS / photo, camera_model='C016') vision = Vision(camera) @@ -70,12 +60,6 @@ def approx_ang(expected): assert y == approx_dist(expected_cartesian.y), "Wrong y-coordinate" assert z == approx_dist(expected_cartesian.z), "Wrong z-coordinate" - polar_x, polar_y, polar_dist = token.legacy_polar - - assert polar_x == approx_ang(expected_polar.polar_x), "Wrong polar_x coordinate" - assert polar_y == approx_ang(expected_polar.polar_y), "Wrong polar_y coordinate" - assert polar_dist == approx_dist(expected_polar.dist), "Wrong polar_dist coordinate" - rot_x, rot_y, dist = token.spherical assert rot_x == approx_ang(expected_spherical.rot_x), "Wrong x-coordinate"