def test_spherical_triangle_surface_area_calculation(self):
     '''Test spherical polygon surface area calculation on the relatively simple case of a spherical triangle on the surface of a unit sphere.'''
     #the surface area of a spherical triangle is a special case of a spherical polygon (http://mathworld.wolfram.com/SphericalTriangle.html)
     sum_spherical_triangle_inner_angles = voronoi_utility.calculate_and_sum_up_inner_sphere_surface_angles_Voronoi_polygon(self.spherical_triangle_coordinate_array,1.0)
     spherical_excess = sum_spherical_triangle_inner_angles - math.pi #because the radius of the sphere is 1 the spherical excess is also the surface area
     self.assertGreater(spherical_excess,0.0)
     test_surface_area = voronoi_utility.calculate_surface_area_of_a_spherical_Voronoi_polygon(self.spherical_triangle_coordinate_array,1.0)
     numpy.testing.assert_almost_equal(test_surface_area,spherical_excess,decimal=12)
 def test_spherical_polygon_4_vertices_surface_area_calculation(self):
     '''Test spherical polygon surface area calculation on the more complex case of a spherical polygon with 4 vertices on a unit sphere.'''
     sum_spherical_polygon_inner_angles = voronoi_utility.calculate_and_sum_up_inner_sphere_surface_angles_Voronoi_polygon(self.spherical_polygon_4_vertices_coord_array,1.0)
     subtraction_value = 2 * math.pi # (n-2) * pi
     target_area = sum_spherical_polygon_inner_angles - subtraction_value
     #print 'target_area (should be pi):', target_area 
     self.assertGreater(sum_spherical_polygon_inner_angles,subtraction_value,'The polygon with 4 vertices has a negative surface area.')
     measured_surface_area = voronoi_utility.calculate_surface_area_of_a_spherical_Voronoi_polygon(self.spherical_polygon_4_vertices_coord_array, 1.0)
     numpy.testing.assert_almost_equal(measured_surface_area,target_area,decimal=12)
 def test_spherical_polygon_4_vertices_sum_inner_angles(self):
     '''Test my spherical polygon inner angle summation code on a slightly more complex case of a spherical polygon with n = 4 vertices. The sum of the inner angles should exceed (n - 2) * pi according to http://mathworld.wolfram.com/SphericalPolygon.html.'''
     theta = voronoi_utility.calculate_and_sum_up_inner_sphere_surface_angles_Voronoi_polygon(
         self.spherical_polygon_4_vertices_coord_array, 1.0)
     minimum_allowed_angle = 2 * math.pi
     self.assertGreater(
         theta,
         minimum_allowed_angle,
         msg=
         'theta must be greater than 2 * pi for spherical polygon with 4 vertices but got theta = {theta}'
         .format(theta=theta))
 def test_spherical_triangle_surface_area_calculation(self):
     '''Test spherical polygon surface area calculation on the relatively simple case of a spherical triangle on the surface of a unit sphere.'''
     #the surface area of a spherical triangle is a special case of a spherical polygon (http://mathworld.wolfram.com/SphericalTriangle.html)
     sum_spherical_triangle_inner_angles = voronoi_utility.calculate_and_sum_up_inner_sphere_surface_angles_Voronoi_polygon(
         self.spherical_triangle_coordinate_array, 1.0)
     spherical_excess = sum_spherical_triangle_inner_angles - math.pi  #because the radius of the sphere is 1 the spherical excess is also the surface area
     self.assertGreater(spherical_excess, 0.0)
     test_surface_area = voronoi_utility.calculate_surface_area_of_a_spherical_Voronoi_polygon(
         self.spherical_triangle_coordinate_array, 1.0)
     numpy.testing.assert_almost_equal(test_surface_area,
                                       spherical_excess,
                                       decimal=12)
 def test_spherical_polygon_4_vertices_surface_area_calculation(self):
     '''Test spherical polygon surface area calculation on the more complex case of a spherical polygon with 4 vertices on a unit sphere.'''
     sum_spherical_polygon_inner_angles = voronoi_utility.calculate_and_sum_up_inner_sphere_surface_angles_Voronoi_polygon(
         self.spherical_polygon_4_vertices_coord_array, 1.0)
     subtraction_value = 2 * math.pi  # (n-2) * pi
     target_area = sum_spherical_polygon_inner_angles - subtraction_value
     #print 'target_area (should be pi):', target_area
     self.assertGreater(
         sum_spherical_polygon_inner_angles, subtraction_value,
         'The polygon with 4 vertices has a negative surface area.')
     measured_surface_area = voronoi_utility.calculate_surface_area_of_a_spherical_Voronoi_polygon(
         self.spherical_polygon_4_vertices_coord_array, 1.0)
     numpy.testing.assert_almost_equal(measured_surface_area,
                                       target_area,
                                       decimal=12)
 def test_spherical_triangle_sum_inner_angles(self):
     '''Test my spherical polygon inner angle summation code on the simple case of a spherical triangle where we know that the sum of the inner angles must be between pi and 3 * pi radians (http://mathworld.wolfram.com/SphericalTriangle.html).'''
     theta = voronoi_utility.calculate_and_sum_up_inner_sphere_surface_angles_Voronoi_polygon(
         self.spherical_triangle_coordinate_array, 1.0)
     self.assertLess(
         theta,
         3. * math.pi,
         msg=
         'theta must be less than 3 * pi radians for a spherical triangle but got theta = {theta}'
         .format(theta=theta))
     self.assertGreater(
         theta,
         math.pi,
         msg=
         'theta must be greater than pi radians for a spherical triangle but got theta = {theta}'
         .format(theta=theta))
 def test_spherical_polygon_4_vertices_sum_inner_angles(self):
     '''Test my spherical polygon inner angle summation code on a slightly more complex case of a spherical polygon with n = 4 vertices. The sum of the inner angles should exceed (n - 2) * pi according to http://mathworld.wolfram.com/SphericalPolygon.html.'''
     theta = voronoi_utility.calculate_and_sum_up_inner_sphere_surface_angles_Voronoi_polygon(self.spherical_polygon_4_vertices_coord_array,1.0)
     minimum_allowed_angle = 2 * math.pi
     self.assertGreater(theta,minimum_allowed_angle,msg='theta must be greater than 2 * pi for spherical polygon with 4 vertices but got theta = {theta}'.format(theta=theta))
 def test_spherical_triangle_sum_inner_angles(self):
     '''Test my spherical polygon inner angle summation code on the simple case of a spherical triangle where we know that the sum of the inner angles must be between pi and 3 * pi radians (http://mathworld.wolfram.com/SphericalTriangle.html).'''
     theta = voronoi_utility.calculate_and_sum_up_inner_sphere_surface_angles_Voronoi_polygon(self.spherical_triangle_coordinate_array,1.0)
     self.assertLess(theta,3. * math.pi,msg='theta must be less than 3 * pi radians for a spherical triangle but got theta = {theta}'.format(theta=theta))
     self.assertGreater(theta,math.pi,msg='theta must be greater than pi radians for a spherical triangle but got theta = {theta}'.format(theta=theta))