Esempio n. 1
0
def signed_straightness(xy1, xy2, xy3):
    vec12 = (xy2[0] - xy1[0], xy2[1] - xy1[1], 0)
    vec32 = (xy2[0] - xy3[0], xy2[1] - xy3[1], 0)
    if vec.length(vec12) > 0 and vec.length(vec32) > 0:
        vec12 = vec.norm(vec12)
        vec32 = vec.norm(vec32)
        sign = 1 if vec.cross(vec12, vec32)[2] > 0 else -1
        return sign * vec.length(vec.add(vec12, vec32))
    else:
        return 0
def signed_straightness(xy1, xy2, xy3):
    vec12 = (xy2[0] - xy1[0], xy2[1] - xy1[1], 0)
    vec32 = (xy2[0] - xy3[0], xy2[1] - xy3[1], 0)
    if vec.length(vec12) > 0 and vec.length(vec32) > 0:
        vec12 = vec.norm(vec12)
        vec32 = vec.norm(vec32)
        sign = 1 if vec.cross(vec12, vec32)[2] > 0 else -1
        return sign * vec.length(vec.add(vec12, vec32))
    else:
        return 0
Esempio n. 3
0
def curve_normal(xy1, xy2, xy3=None):
    if xy3 == None:
        xy3 = xy2
        xy2 = vec.scale(vec.add(xy1, xy2), 0.5)

    if vec.colinear(vec.sub(xy2, xy1), vec.sub(xy3, xy2)):
        xy2 = (xy2[0] + gauss(0, 0.001), xy2[1] + gauss(0, 0.001))

    vec12 = vec.norm((xy2[0] - xy1[0], xy2[1] - xy1[1]))
    vec32 = vec.norm((xy2[0] - xy3[0], xy2[1] - xy3[1]))

    return vec.norm(vec.add(vec12, vec32))
def curve_normal(xy1, xy2, xy3=None):
    if xy3 == None:
        xy3 = xy2
        xy2 = vec.scale(vec.add(xy1, xy2), 0.5)

    if vec.colinear(vec.sub(xy2, xy1), vec.sub(xy3, xy2)):
        xy2 = (xy2[0] + gauss(0, 0.001), xy2[1] + gauss(0, 0.001))

    vec12 = vec.norm((xy2[0] - xy1[0], xy2[1] - xy1[1]))
    vec32 = vec.norm((xy2[0] - xy3[0], xy2[1] - xy3[1]))

    return vec.norm(vec.add(vec12, vec32))
Esempio n. 5
0
def ccw(x, y, z):
    x = (x[0], x[1], 0)
    y = (y[0], y[1], 0)
    z = (z[0], z[1], 0)
    vec12 = vec.sub(y, x)
    vec32 = vec.sub(z, x)
    if vec.length(vec12) > 0 and vec.length(vec32) > 0:
        vec12 = vec.norm(vec12)
        vec32 = vec.norm(vec32)
        sign = -1 if vec.cross(vec12, vec32)[2] > 0 else 1
        return sign * vec.length(vec.cross(vec12, vec32))
    else:
        return 0
def ccw(x, y, z):
    x = (x[0], x[1], 0)
    y = (y[0], y[1], 0)
    z = (z[0], z[1], 0)
    vec12 = vec.sub(y, x)
    vec32 = vec.sub(z, x)
    if vec.length(vec12) > 0 and vec.length(vec32) > 0:
        vec12 = vec.norm(vec12)
        vec32 = vec.norm(vec32)
        sign = -1 if vec.cross(vec12, vec32)[2] > 0 else 1
        return sign * vec.length(vec.cross(vec12, vec32))
    else:
        return 0
Esempio n. 7
0
def straightness(xy1, xy2, xy3):
    vec12 = vec.norm((xy2[0] - xy1[0], xy2[1] - xy1[1]))
    vec32 = vec.norm((xy2[0] - xy3[0], xy2[1] - xy3[1]))
    return vec.length(vec.add(vec12, vec32))
def straightness(xy1, xy2, xy3):
    vec12 = vec.norm((xy2[0] - xy1[0], xy2[1] - xy1[1]))
    vec32 = vec.norm((xy2[0] - xy3[0], xy2[1] - xy3[1]))
    return vec.length(vec.add(vec12, vec32))