Exemple #1
0
def get_corner_position(p1, p2, p3, val):
	teta = get_3_points_angle_2d(p1, p2, p3)
	if False:#(pi - abs(teta)) < 0.001:
		o3 = get_line_offset(p1,p3,val)
		position = o3 + p2
	else:
		o1 = get_line_offset(p1,p2,val)
		o2 = get_line_offset(p2,p3,val)
		lp1 = Vector((p1.x+o1.x, p1.y+o1.y, 0))
		lp2 = Vector((p2.x+o1.x, p2.y+o1.y, 0))
		lp3 = Vector((p2.x+o2.x, p2.y+o2.y, 0))
		lp4 = Vector((p3.x+o2.x, p3.y+o2.y, 0))
		position = get_lines_intersection(lp1,lp2,lp3,lp4)
	if position == None:
		# avod the not spected errores
		position = o1 + p2
	return position
Exemple #2
0
 def scan(section1, section2):
     diva, divb, points = [], [], []
     for s1s, s1e in section1:
         b1 = segment1.boundingbox(s1s, s1e, 30)
         for s2s, s2e in section2:
             b2 = segment2.boundingbox(s2s, s2e, 30)
             if b1.is_colide_with(b2):
                 """ devide bonding box untill one of edge smaller than tollerance """
                 diva = get_devide_range(
                     s1s, s1e) if b1.width > t and b1.length > t else [[
                         s1s, s1e
                     ]]
                 divb = get_devide_range(
                     s2s, s2e) if b2.width > t and b2.length > t else [[
                         s2s, s2e
                     ]]
                 if (b1.width <= t or b1.length <= t) and (b2.width <= t or
                                                           b2.length <= t):
                     """ if both bondig boxes are smaller then tollerance """
                     """ get line between start and end of each bonding box """
                     p1 = segment1.get_point_on(s1s)
                     p2 = segment1.get_point_on(s1e)
                     p3 = segment2.get_point_on(s2s)
                     p4 = segment2.get_point_on(s2e)
                     """ get cros point of lines """
                     co = get_lines_intersection(p1, p2, p3, p4)
                     time1 = get_cros_time(s1s, s1e, p1, p2, co)
                     time2 = get_cros_time(s2s, s2e, p3, p4, co)
                     points.append(
                         CurveIntersectionPoint(segment1, time1, segment2,
                                                time2, co))
                 else:
                     """ rescan divided boxes """
                     points += scan(diva, divb)
     """ remove doubles """
     retpoints = []
     for p in points:
         overlap = False
         for r in retpoints:
             if get_distance(p.co, r.co) < tollerance / 10:
                 overlap = True
                 break
         if not overlap:
             retpoints.append(p)
     return retpoints