Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- class Dot:
- def __init__(self):
- self.x = 0
- self.y = 0
- def __init__(self, x1, y1):
- self.x = x1
- self.y = y1
- def distance(self, d):
- a = ( (self.x - d.x)**2 + (self.y - d.y)**2 )**(0.5)
- return a
- #///////////////////////////////////////////////////////
- class Trangle:
- def __init__(self, dot_a, dot_b, dot_c):
- self.a = dot_a
- self.b = dot_b
- self.c = dot_c
- def p(self):
- p = self.a.distance(self.b) + self.c.distance(self.b) + self.a.distance(self.c)
- return p
- def s(self):
- p = self.p()/2
- s = (p * (p - self.a.distance(self.b)) * (p - self.c.distance(self.b)) * (p - self.a.distance(self.c)) )**(0.5)
- return s
- def isExists(self):
- bol = True
- if(self.a.distance(self.b) + self.c.distance(self.b) <= self.a.distance(self.c) and
- (self.a.distance(self.c)+ self.c.distance(self.b) <= self.a.distance(self.b)) and
- (self.a.distance(self.b) + self.a.distance(self.c) <= self.c.distance(self.b))):
- bol = False
- return bol
- #///////////////////////////////////////////////////////
- dot_1 = Dot(0,0)
- dot_2 = Dot(5,5)
- dot_3 = Dot(5,2)
- trang = Trangle(dot_1, dot_2, dot_3)
- print(trang.p())
- print(trang.s())
- print(trang.isExists())
Add Comment
Please, Sign In to add comment