예제 #1
0
 def test_angle_from_points(self):
     for x in self.angle_checks:
         angle = Triangle.angle_from_points(x[0], x[2], x[1])
         self.assertAlmostEqual(
             x[3], angle, places=10,
             msg="Check failed for: {}; result is: {}".format(x, angle)
         )
예제 #2
0
    def central_angle(start_point, end_point, arc_point):
        """
        Calculates the measure in radians of the arc between <start_point> and <end_point>
        and containing <arc_point> in the circumscribed circle.

        The result is equal to the central angle (S-O-E).

        The inscribed angle S-A-E can be calculated as:

            angle(S-A-E) = pi - angle(S-O-E) / 2

        On degenerate input (e.g. identical start/end/arc points) will raise ValueError.

                         A
                S _..-~~~+-._ E                  S _..-~~~--._ E
               ,-+           +-.                ,-+           +-.
             ,'   \         /   `.            ,'   \         /   `.
            /      \       /      \          /      \       /      \
           /        \angle/        \        /        \     /        \
          /          \.-./          \      /         ,\   /.         \
         ;            \ /            :    ;         /  \ /  \         :
         |             +             |    |        (    +    )        |
         :             O             ;    :         \   O   /         ;
          \                         /      \         `-----'         /
           \                       /        \         angle         /
            \                     /          \                     /
             `.                 ,'            `.                 ,'
               '-.          _.-'                '+.          _.-'
                  `'------''                    A  `'------''

        Notation:
            S -> start_point
            E -> end_point
            A -> arc_point
            angle -> result (expressed in radians)
        """
        inscribed_angle = Triangle.angle_from_points(start_point, arc_point,
                                                     end_point)
        return 2.0 * (math.pi - inscribed_angle)
예제 #3
0
    def central_angle(start_point, end_point, arc_point):
        """
        Calculates the measure in radians of the arc between <start_point> and <end_point>
        and containing <arc_point> in the circumscribed circle.

        The result is equal to the central angle (S-O-E).

        The inscribed angle S-A-E can be calculated as:

            angle(S-A-E) = pi - angle(S-O-E)/2

        On degenerate input (e.g. identical start/end/arc points) will raise ValueError.

                         A
                S _..-~~~+-._ E                  S _..-~~~--._ E
               ,-+           +-.                ,-+           +-.
             ,'   \         /   `.            ,'   \         /   `.
            /      \       /      \          /      \       /      \
           /        \angle/        \        /        \     /        \
          /          \.-./          \      /         ,\   /.         \
         ;            \ /            :    ;         /  \ /  \         :
         |             +             |    |        (    +    )        |
         :             O             ;    :         \   O   /         ;
          \                         /      \         `-----'         /
           \                       /        \         angle         /
            \                     /          \                     /
             `.                 ,'            `.                 ,'
               '-.          _.-'                '+.          _.-'
                  `'------''                    A  `'------''

        Notation:
            S -> start_point
            E -> end_point
            A -> arc_point
            angle -> result (expressed in radians)
        """
        inscribed_angle = Triangle.angle_from_points(start_point, arc_point, end_point)
        return 2.0 * (math.pi - inscribed_angle)