Beispiel #1
0
def test_angle_3points_half_pi():
    orig = (0.0, 0.0, 0.0)
    vec1 = (1.0, 0.0, 0.0)
    vec2 = (0.0, 2.0, 0.0)
    nt.eq_(angle_3points(orig, vec1, vec2), pi / 2.0)

    vec2 = (0.0, 0.0, 3.0)
    nt.eq_(angle_3points(orig, vec1, vec2), pi / 2.0)

    vec2 = (0.0, 0.0, -3.0)
    nt.eq_(angle_3points(orig, vec1, vec2), pi / 2.0)

    vec1 = (0.0, 4.0, 0.0)
    nt.eq_(angle_3points(orig, vec1, vec2), pi / 2.0)
Beispiel #2
0
def test_angle_3points_equal_points_returns_nan():
    vec1 = (1.0, 0.0, 0.0)
    vec2 = (0.0, 1.0, 0.0)
    orig = (0.0,1.0,0.0)
    a = angle_3points(orig,vec1,vec2)
    nt.ok_(np.isnan(a))
    nt.ok_(math.isnan(a))
Beispiel #3
0
def local_bifurcation_angle(bifurcation_point):
    '''Return the opening angle between two out-going segments
    in a bifurcation point
    '''
    return mm.angle_3points(bifurcation_point.value,
                            bifurcation_point.children[0].value,
                            bifurcation_point.children[1].value)
Beispiel #4
0
def local_bifurcation_angle(bifurcation_point):
    '''Return the opening angle between two out-going segments
    in a bifurcation point
    '''
    return mm.angle_3points(bifurcation_point.value,
                            bifurcation_point.children[0].value,
                            bifurcation_point.children[1].value)
Beispiel #5
0
def test_angle_3points_quarter_pi():
    orig = (0.0, 0.0, 0.0)
    vec1 = (1.0, 0.0, 0.0)
    vec2 = (2.0, 2.0, 0.0)
    nt.assert_equal(angle_3points(orig, vec1, vec2), pi / 4.0)

    vec2 = (3.0, 3.0, 0.0)
    nt.assert_equal(angle_3points(orig, vec1, vec2), pi / 4.0)

    vec2 = (3.0, -3.0, 0.0)
    nt.assert_equal(angle_3points(orig, vec1, vec2), pi / 4.0)

    vec2 = (3.0, 0.0, 3.0)
    nt.assert_equal(angle_3points(orig, vec1, vec2), pi / 4.0)

    vec2 = (3.0, 0.0, -3.0)
    nt.assert_equal(angle_3points(orig, vec1, vec2), pi / 4.0)
Beispiel #6
0
def i_segment_meander_angle(tree):
    '''Return an iterator to a tree meander angle

    The meander angle is defined as the angle between to adjacent  segments.
    Applies neurom.morphmath.angle_3points to triplets of
    '''

    return tr.imap_val(lambda t: mm.angle_3points(t[1], t[0], t[2]), tr.itriplet(tree))
Beispiel #7
0
def i_segment_meander_angle(tree):
    '''Return an iterator to a tree meander angle

    The meander angle is defined as the angle between to adjacent  segments.
    Applies neurom.morphmath.angle_3points to triplets of
    '''

    return tr.imap_val(lambda t: mm.angle_3points(t[1], t[0], t[2]),
                       tr.itriplet(tree))
Beispiel #8
0
def test_i_remote_bifurcation_angles():
    T = BRANCHING_TREE

    # (fork point, end point, end point) tuples calculated by hand
    # from BRANCHING_TREE
    refs = (((0, 4, 0), (0, 5, 0), (15, 15, 0)),
            ((0, 5, 0), (4, 5, 0), (0, 5, 3)),
            ((0, 5, 3), (0, 6, 3), (0, 6, 4)))

    ref_angles = tuple(angle_3points(p[0], p[1], p[2]) / math.pi for p in refs)
    ref = (0.2985898, 0.5, 0.25)  # ref angles in pi radians
    # sanity check
    for i, b in enumerate(ref_angles):
        nt.assert_almost_equal(b, ref[i])

    for i, b in enumerate(i_remote_bifurcation_angle(T)):
        nt.assert_almost_equal(b / math.pi, ref_angles[i])
        nt.assert_almost_equal(b / math.pi, ref[i])
Beispiel #9
0
def remote_angle(bifurcation_point):
    '''Calculate the remote bifurcation angle'''
    end_points = tuple(p for p in tr.i_branch_end_points(bifurcation_point))
    return mm.angle_3points(bifurcation_point.value,
                            end_points[0].value,
                            end_points[1].value)
Beispiel #10
0
def test_angle_3points():
    vec1 = (1.0, 0.0, 0.0)
    vec2 = (0.0, 1.0, 0.0)
    orig = (0.0,0.0,0.0)
    angle=angle_3points(orig, vec1, vec2)
    nt.ok_(angle==pi/2.0)
Beispiel #11
0
def test_angle_3points_collinear_returns_zero():
    orig = (0.0, 0.0, 0.0)
    vec1 = (1.0, 1.0, 1.0)
    vec2 = (2.0, 2.0, 2.0)
    angle=angle_3points(orig, vec1, vec2)
    nt.assert_equal(angle, 0.0)
Beispiel #12
0
def test_angle_3points_opposing_returns_pi():
    orig = (0.0, 0.0, 0.0)
    vec1 = (1.0, 1.0, 1.0)
    vec2 = (-2.0, -2.0, -2.0)
    angle=angle_3points(orig, vec1, vec2)
    nt.assert_equal(angle, pi)
Beispiel #13
0
def test_angle_3points_equal_points_returns_zero():
    orig = (0.0, 1.0, 0.0)
    vec1 = (1.0, 0.0, 0.0)
    vec2 = (0.0, 1.0, 0.0)
    a = angle_3points(orig, vec1, vec2)
    nt.assert_equal(a, 0.0)
Beispiel #14
0
def meander_angle(triplet):
    '''Return the angle between a triplet of consecutive points'''
    return mm.angle_3points(triplet[1], triplet[0], triplet[2])
Beispiel #15
0
 def _remangle(t):
     '''Helper to calculate the remote angle'''
     end_points = tuple(p for p in tr.i_branch_end_points(t))
     return mm.angle_3points(t.value, end_points[0].value, end_points[1].value)
Beispiel #16
0
 def _remangle(t):
     '''Helper to calculate the remote angle'''
     end_points = tuple(p for p in tr.i_branch_end_points(t))
     return mm.angle_3points(t.value, end_points[0].value,
                             end_points[1].value)