示例#1
0
def check_flatness(p0, p1, p2, tlr=0.5):
    p0, p1, p2 = (base_point(p) for p in (p0, p1, p2))
    if p0 == p1 or p1 == p2:
        return True
    a1 = get_point_angle(p1, p0)
    a2 = get_point_angle(p2, p1)
    return abs(a2 - a1) < tlr
示例#2
0
def _get_point_on_path(flatpath, pos):
    start = flatpath[0]
    end = flatpath[0]
    point = None
    lenght = 0
    for item in flatpath[1]:
        start, end = end, item
        lenght += distance(start, end)
        if lenght >= pos:
            coef = 1.0 - (lenght - pos) / distance(start, end)
            point = midpoint(start, end, coef)
            break
    if not point:
        last = distance(start, end)
        coef = (pos - lenght + last) / last
        point = midpoint(start, end, coef)
    angle = get_point_angle(end, start)
    return point, angle
示例#3
0
def _get_point_on_path(flat_path, pos):
	start = flat_path[0]
	end = flat_path[0]
	point = None
	l = 0
	for item in flat_path[1]:
		start, end = end, item
		l += distance(start, end)
		if l >= pos:
			coef = 1.0 - (l - pos) / distance(start, end)
			point = midpoint(start, end, coef)
			break
	if not point:
		last = distance(start, end)
		coef = (pos - l + last) / last
		point = midpoint(start, end, coef)
	angle = get_point_angle(end, start)
	return point, angle