Changeset 1366


Ignore:
Timestamp:
May 11, 2005, 2:11:54 PM (20 years ago)
Author:
steve
Message:

unit tested radius calculations for equilateral and right-angled triangles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/test_mesh.py

    r1158 r1366  
    208208        mesh.check_integrity()
    209209
    210 
     210    def test_inscribed_circle_equilateral(self):
     211        """test that the radius is calculated correctly by mesh in the case of an equilateral triangle"""
     212        a = [0.0, 0.0]
     213        b = [2.0, 0.0]
     214        c = [1.0, sqrt(3.0)]
     215
     216        points = [a, b, c]
     217        vertices = [[0,1,2]]
     218
     219        mesh = Mesh(points, vertices,use_inscribed_circle=False)
     220        assert allclose(mesh.radii[0],sqrt(3.0)/3),'Steve''s doesn''t work'
     221
     222        mesh = Mesh(points, vertices,use_inscribed_circle=True)
     223        assert allclose(mesh.radii[0],sqrt(3.0)/3),'inscribed circle doesn''t work'
     224
     225    def test_inscribed_circle_rightangle_triangle(self):
     226        """test that the radius is calculated correctly by mesh in the case of a right-angled triangle"""
     227        a = [0.0, 0.0]
     228        b = [4.0, 0.0]
     229        c = [0.0, 3.0]
     230
     231        points = [a, b, c]
     232        vertices = [[0,1,2]]
     233
     234        mesh = Mesh(points, vertices,use_inscribed_circle=False)
     235        assert allclose(mesh.radii[0],5.0/6),'Steve''s doesn''t work'
     236
     237        mesh = Mesh(points, vertices,use_inscribed_circle=True)
     238        assert allclose(mesh.radii[0],1.0),'inscribed circle doesn''t work'
    211239
    212240
Note: See TracChangeset for help on using the changeset viewer.