示例#1
0
 def draw(self, component: Union["_BufferedLineSegment", "_BufferedArc"]):
     pos = self.path.currentPosition()
     pos = Vector(pos.x(), pos.y(), 0)
     start = component.start_point()
     jump_distance = pos.distance(start.xy)  # compare 2D to 2D
     if jump_distance > 1e-5:
         if not self.first_component:
             print(f'warning: non-contiguous polyline: {self.current_entity}. '
                   f'Jump from {pos} to {start} (distance of {jump_distance})')
         self.path.moveTo(start.x, start.y)
     component.draw(self.path)
     if self.color is None:
         self.color = component.color
     elif component.color != self.color:
         print(f'warning: component has different color to the polyline {component.color} != {self.color}')
     self.first_component = False
示例#2
0
文件: math.py 项目: bedlamzd/vkr
def diap(start, end, step=1) -> List[float]:
    """ Принимает две точки пространства и возвращает точки распределенные на заданном расстоянии
     между данными двумя.
    :param Iterable[float] start: начальная точка в пространстве
    :param Iterable[float] end: конечная точка в пространстве
    :param float step: шаг между точками
    :return: точка между start и end
    """
    start = Vector(start)
    end = Vector(end)
    d = start.distance(end)
    number_of_steps = int(d / step)
    ratio = step / d
    for i in range(number_of_steps):
        yield list(start.lerp(end, i * ratio))
    yield list(end)