예제 #1
0
 def __sub__(self, other: Point or Iterable or Vector):
     if type(other) == Vector:
         return Vector(self.start_point - other.start_point, self.end_point - other.end_point)
     other = Point.check_Point(other)
     start = self.start_point - other
     end = self.end_point - other
     return Vector(start, end)
예제 #2
0
 def move_to_point(self, new_start_point: Point or Iterable) -> None:
     """
     Перемещает начало вектора к заданной точке.
     :param new_start_point: Точка куда необходимо перенести вектор.
     """
     new_start_point = Point.check_Point(new_start_point)
     dif_val = self.start_point - new_start_point
     self.start_point -= dif_val
     self.end_point -= dif_val
예제 #3
0
    def __init__(self, point1: Point or Iterable, point2: Point or Iterable = None):
        """
        Создает вектор плоскости. Если дана только одна точка, то вектор счетается радиус-вектором(начало в (0,0)).
        :param point1: Точка начала вектора относительно С.О.
        :param point2: Точка конца вектора относительно С.О.
        """
        point1 = Point.check_Point(point1)

        if type(point2) is None:
            if point1.z is None:
                self.start_point: Point = Point(0, 0)
            else:
                self.start_point: Point = Point(0, 0, 0)
            self.end_point: Point = point1
        else:
            point2 = Point.check_Point(point2)
            if (point1.z is None and point2.z is None) or (point1.z is not None and point2.z is not None):
                self.start_point: Point = point1
                self.end_point: Point = point2
            else:
                raise TypeError("Flat and 3D points used in one Vector obj.")