Skip to content
Snippets Groups Projects
Commit 8cf00d93 authored by Sepehr Bayat's avatar Sepehr Bayat
Browse files

Delete Triangle.py

parent 21a9c6c1
No related branches found
No related tags found
No related merge requests found
## @file Triangle.py
# @author Sepehr
# @brief Provides the Triangle CLass for Perimeter Area and existence of triangle
# @date 25 Jan 2018
from PointADT import *
##@brief An ADT that respresents a 2D point
class Triangle:
## @brief Triangle constructor
# @details Initializes a Triangle with three points a,b,c
# @param a center of triangle
# @param b center of triangle
# @param c center of triangle
def __init__(self, p1, p2,p3):
self.__a = p1
self.__b = p2
self.__c = p3
## @brief Gets the center_a
# @return The point of type pointT
def point_a(self):
return self.__a
## @brief Gets the center_a
# @return The point of type pointT
def point_b(self):
return self.__b
## @brief Gets the center_a
# @return The point of type pointT
def point_c(self):
return self.__c
## @brief Gets the sides
# @return The sides of the triangle
def sides(self):
AB = pointT.dist(self.point_a(),self.point_b())
AC = pointT.dist(self.point_a(),self.point_c())
BC = pointT.dist(self.point_b(),self.point_c())
return [AB,AC,BC]
## @brief Inequality theorem
# @return the existence of a triangle
def inequality_theorem(self):
AB,AC,BC = self.sides()
if (AB +AC > BC and AB+BC > AC and AC+BC >AB):
return True;
else:
return False;
## @brief perimeter
# @return the perimeter of the triangle
def perimeter_of_triangle(self):
AB,AC,BC = self.sides()
return AB+AC+BC
## @brief area
# @return the area of the triangle
def area_of_triangle(self):
AB,AC,BC = self.sides()
P = (AB+AC+BC)/2
return sqrt(P*(P-AB)*(P-AC)*(P-BC))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment