homework_04/12_Martin_Vrachev/circles.py
def find_relative_position(self, circle):
        '''
        Find relative position of two circles
        '''
        try:
            assert isinstance(circle, Circle)
        except AssertionError:
            print('The function takes type Circle as a paramater!')
            sys.exit()

        # Same
        if self.center.x_coordinate == circle.center.x_coordinate and \
         self.center.y_coordinate == circle.center.y_coordinate and self.radius == circle.radius:
            return RelativePosition.SAME

        a_b = abs(distance(self.center, circle.center))
        radii_sum = self.radius + circle.radius
        radii_sub = abs(self.radius - circle.radius)

        # No common points
        if a_b > radii_sum or a_b < radii_sub:
            return RelativePosition.NO_COMMON_POINTS

        # Touching
        if a_b in (radii_sum, radii_sub):
            return RelativePosition.TOUCHING

        # Intersecting
        if radii_sub < a_b < radii_sum:
            return RelativePosition.INTERSECTING

        return None

        Find relative position of two circles
        
Find relative position of two circles
Find relative position of two circles
def find_relative_position(self, circle):
        try:
            assert isinstance(circle, Circle)
        except AssertionError:
            print('The function takes type Circle as a paramater!')
            sys.exit()
        if self.center.x_coordinate == circle.center.x_coordinate and \
         self.center.y_coordinate == circle.center.y_coordinate and self.radius == circle.radius:
            return RelativePosition.SAME
        a_b = abs(distance(self.center, circle.center))
        radii_sum = self.radius + circle.radius
        radii_sub = abs(self.radius - circle.radius)
        if a_b > radii_sum or a_b < radii_sub:
            return RelativePosition.NO_COMMON_POINTS
        if a_b in (radii_sum, radii_sub):
            return RelativePosition.TOUCHING
        if radii_sub < a_b < radii_sum:
            return RelativePosition.INTERSECTING
        return None
def find_relative_position ( self , circle ) : try : assert isinstance ( circle , Circle ) except AssertionError : print ( 'The function takes type Circle as a paramater!' ) sys . exit ( ) if self . center . x_coordinate == circle . center . x_coordinate and self . center . y_coordinate == circle . center . y_coordinate and self . radius == circle . radius : return RelativePosition . SAME a_b = abs ( distance ( self . center , circle . center ) ) radii_sum = self . radius + circle . radius radii_sub = abs ( self . radius - circle . radius ) if a_b > radii_sum or a_b < radii_sub : return RelativePosition . NO_COMMON_POINTS if a_b in ( radii_sum , radii_sub ) : return RelativePosition . TOUCHING if radii_sub < a_b < radii_sum : return RelativePosition . INTERSECTING return None
Find relative position of two circles
Find relative position of two circles
'''
        Find relative position of two circles
        ''' # Same # No common points # Touching # Intersecting
self
circle