summaryrefslogtreecommitdiff
path: root/python-func/task11.py
blob: cd759fd4dd4ec3d68ac233925f047d21c62a915a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from math import sqrt


class Point:
    def __init__(self, x: float, y: float):
        self.x = x
        self.y = y


def dist(p1: Point, p2: Point) -> float:
    return sqrt((p2.x - p1.x) ** 2 + (p2.y - p1.y) ** 2)


def area_triangle(p1: float, p2: float, p3: float) -> float:
    p = (a + b + c) / 2
    return sqrt(p * (p - a) * (p - b) * (p - c))


def solve(a: Point, b: Point, c: Point, d: Point, e: Point) -> float:
    ab = dist(a, b)
    ac = dist(a, c)
    ad = dist(a, d)
    ae = dist(a, e)
    bc = dist(b, c)
    cd = dist(c, d)
    de = dist(d, e)

    a1 = area_triangle(ab, bc, ac)
    a2 = area_triangle(ac, cd, ad)
    a3 = area_triangle(ad, de, ae)

    return a1 + a2 + a3


ax, ay = map(int, input("Ax, Ay = ").split())
bx, by = map(int, input("Bx, By = ").split())
cx, cy = map(int, input("Cx, Cy = ").split())
dx, dy = map(int, input("Dx, Dy = ").split())
ex, ey = map(int, input("Ex, Ey = ").split())

res = solve( Point(ax, ay)
           , Point(bx, by)
           , Point(cx, cy)
           , Point(dx, dy)
           , Point(ex, ey) )

print(f"Площадь фигуры со введёнными точками равна {res}")