def test_angles(self):
     c = Camera(math.pi/2, 1920, 1080, [0,0,0], [math.pi/2, 0])
     genome = np.array([0, 0, 0, math.pi/2, 0])
     o1 = Object("o1", np.array([1, 1, 0]))
     xa, ya = FitnessFunction.getImageAngles(genome, o1)
     x = xa * 2.0 / c.aperture_angle
     y = ya * 2.0 * c.resolution_x / (c.aperture_angle * c.resolution_y )
     self.assertAlmostEqual(x, 1, 5)
     self.assertAlmostEqual(y, 0, 5)
     o2 = Object("o2", np.array([0, 1, tan(c.aperture_angle / 2 * c.resolution_y / c.resolution_x)]))
     xa, ya = FitnessFunction.getImageAngles(genome, o2)
     x = xa * 2.0 / c.aperture_angle
     y = ya * 2.0 * c.resolution_x / (c.aperture_angle * c.resolution_y )
     self.assertAlmostEqual(x, 0, 5)
     self.assertAlmostEqual(y, 1, 5)
     o3 = Object("o3", np.array([0.5, 1, 0.5 * tan(c.aperture_angle / 2 * c.resolution_y / c.resolution_x)]))
     xa, ya = FitnessFunction.getImageAngles(genome, o3)
     x = xa * 2.0 / c.aperture_angle
     y = ya * 2.0 * c.resolution_x / (c.aperture_angle * c.resolution_y )
     self.assertAlmostEqual(x, arctan(0.5) / (c.aperture_angle / 2), 2)
     self.assertAlmostEqual(y, arctan(0.5) / (c.aperture_angle * c.resolution_y / c.resolution_x), 0)
     genome = np.array([0, 0, 0, math.pi/2, -math.pi/4])
     xa, ya = FitnessFunction.getImageAngles(genome, o1)
     x = xa * 2.0 / c.aperture_angle
     y = ya * 2.0 * c.resolution_x / (c.aperture_angle * c.resolution_y )
     self.assertAlmostEqual(x, 0, 5)
     self.assertAlmostEqual(y, 0, 5)
     genome = np.array([0, 0, 0, math.pi/2, math.pi/4])
     xa, ya = FitnessFunction.getImageAngles(genome, o1)
     x = xa * 2.0 / c.aperture_angle
     y = ya * 2.0 * c.resolution_x / (c.aperture_angle * c.resolution_y )
     self.assertAlmostEqual(x, 2, 5)
     self.assertAlmostEqual(y, 0, 5)
     genome = np.array([0, 0, 0, math.pi/2, math.pi/2])
     xa, ya = FitnessFunction.getImageAngles(genome, o1)
     x = xa * 2.0 / c.aperture_angle
     y = ya * 2.0 * c.resolution_x / (c.aperture_angle * c.resolution_y )
     self.assertAlmostEqual(x, 3, 5)
     self.assertAlmostEqual(y, 0, 5)
     genome = np.array([0, 0, 0, math.pi/2, math.pi])
     xa, ya = FitnessFunction.getImageAngles(genome, o1)
     x = xa * 2.0 / c.aperture_angle
     y = ya * 2.0 * c.resolution_x / (c.aperture_angle * c.resolution_y )
     self.assertAlmostEqual(x, 3, 5)
     self.assertAlmostEqual(y, 0, 5)