コード例 #1
0
def test1_1():
    """
    This test function builds a triangle with the points
        - (0, 0, 0)
        - (0, 1, 0)
        - (1, 0, 0)
    and then has its area and cotangentes values computed by
    the smoothing library.
    Results should be :
        - area = 0.5
        - cotan(A) = 0, cotan(B) = 1, cotan(C) = 1
    
    """
    vertices = np.array([[0.,0.,0.], [0., 1., 0.], [1., 0., 0.]])
    polygons = np.array([[0, 1, 2]])
    areas, cotangentes = smooth.compute_areas_and_cotangentes(polygons, vertices)

    assert (areas.shape == (1,) and areas[0] == 0.5)
    assert (cotangentes.shape == (3,1) and \
            np.all(np.equal(cotangentes, np.array([[0.], [1.], [1.]]))))
コード例 #2
0
def test1_2():
    """
    This test function builds two triangles, respectively with the points
        - (0, 0, 0), (0, 1, 0), (1, 0, 0)
        - (0, 1, 0), (1, 0, 0), (0, 0, 1)
    and then has their areas and cotangentes values computed by
    the smoothing library.
    Results should be :
        - areas = (0.5, sqrt(3)/2)
        - cotan(A) = (0, 1/sqrt(3)),
          cotan(B) = (1, 1/sqrt(3)),
          cotan(C) = (1, 1/sqrt(3))
    
    """
    vertices = np.array([[0.,0.,0.], [0., 1., 0.], [1., 0., 0.], [0., 0., 1.]])
    polygons = np.array([[0, 1, 2], [1, 2, 3]])
    areas, cotangentes = smooth.compute_areas_and_cotangentes(polygons, vertices)

    assert (areas.shape == (2,))
    assert (np.all(np.equal(areas, np.array([0.5, np.sqrt(3)/2]))))
    assert (cotangentes.shape == (3,2))
    assert (np.all(np.equal(cotangentes, np.array([[0., 1/np.sqrt(3)],
                                                   [1., 1/np.sqrt(3)],
                                                   [1., 1/np.sqrt(3)]]))))