Как рассчитать все параметры треугольника?

Для расчета основных параметров треугольника (таких как: периметр, площадь, длины сторон, углы, координаты, радиусы вписанной и описанной окружностей, а также координаты их центров) можно воспользоваться следующим классом TTriangle. Все формулы, используемые в коде, а также пример работы класса в практической реализации см. на странице "Расчет треугольника"

 
TTriangle = class
  private
    fx1, fy1 : Double;
    fx2, fy2 : Double;
    fx3, fy3 : Double;
    function GetDistAB: Double;
    function GetDistAC: Double;
    function GetDistBC: Double;
    function GetPerimeter: Double;
    function GetArea: Double;
    function GetAngleA: Double;
    function GetAngleB: Double;
    function GetAngleC: Double;
    function GetRadiusIn: Double;
    function GetRadiusOut: Double;
    function GetCenterOut: TFPoint;
    function GetCenterIn: TFPoint;
    function PointsInLine: Boolean;
  public
    // Задание треугольника координатами его вершин
    constructor Create( ax1,ay1, ax2,ay2, ax3,ay3: Double); overload;
    // Задание треугольника длинами его сторон
    constructor Create( a, b, c: Double); overload;
    //функция нахождения длины отрезка
    function Dist( ax1, ay1, ax2, ay2: Double): Double;   
  published
    // координаты первой вершины A
    property X1: Double read fx1 write fx1;
    property Y1: Double read fy1 write fy1;
    // координаты второй вершины B
    property X2: Double read fx2 write fx2;
    property Y2: Double read fy2 write fy2;
    // координаты третьей вершины С
    property X3: Double read fx3 write fx3;
    property Y3: Double read fy3 write fy3;
    property DistAB: Double read GetDistAB; // Длина AB
    property DistBC: Double read GetDistBC; // Длина BC
    property DistAC: Double read GetDistAC; // Длина AC
    property Perimeter: Double read GetPerimeter; // Периметр
    property Area: Double read GetArea;  // Площадь
    property AngleA: Double read GetAngleA; // Угол A
    property AngleB: Double read GetAngleB; // Угол B
    property AngleC: Double read GetAngleC; // Угол C
    // Радиус вписанной окружности
    property RadiusIn: Double read GetRadiusIn;
    // Радиус описанной окружности 
    property RadiusOut: Double read GetRadiusOut;
    // Центр описанной окружности
    property CenterOut: TFPoint read  GetCenterOut;
    // Центр вписанной окружности
    property CenterIn: TFPoint read  GetCenterIn;
  end;
 
{ TTriangle }
 
constructor TTriangle.Create(ax1, ay1, ax2, ay2, ax3, ay3: Double);
begin
  fx1 := ax1;
  fy1 := ay1;
  fx2 := ax2;
  fy2 := ay2;
  fx3 := ax3;
  fy3 := ay3;
end;
 
 
constructor TTriangle.Create(a, b, c: Double);
Var cosa: Double;
begin
  fx1 := 0;
  fy1 := 0;
  fx2 := 0;
  fy2 := c;
  cosa := (b*b+c*c - a*a)/(2*b*c);
  fy3 := b * cosa;
  fx3 := b * sin(arccos(cosA));
end;
 
 
function TTriangle.Dist(ax1, ay1, ax2, ay2: Double): Double;
begin
 Result := sqrt((ax2-ax1)*(ax2-ax1)+(ay2-ay1)*(ay2-ay1));
end;
 
 
function TTriangle.GetAngleA: Double;
Var a, r: Double;
begin
 a := (fx2-fx1)*(fx3-fx1)+(fy2-fy1)*(fy3-fy1);
 r := a/DistAB/DistAC;
 Result := arccos(r);
end;
 
 
function TTriangle.GetAngleB: Double;
Var a, r: Double;
begin
 a := (fx1-x2)*(fx3-fx2)+(fy1-fy2)*(fy3-fy2);
 r := a/DistAB/DistBC;
 Result := arccos(r);
end;
 
 
function TTriangle.GetAngleC: Double;
Var a, r: Double;
begin
 a := (fx2-x3)*(fx1-fx3)+(fy2-fy3)*(fy1-fy3);
 r := a/DistBC/DistAC;
 Result := arccos(r);
end;
 
 
function TTriangle.GetArea: Double;
begin
 Result := sqrt((Perimeter/2*(Perimeter/2-DistAB)*
                (Perimeter/2-DistBC)*(Perimeter/2-DistAC)));
end;
 
 
function TTriangle.GetCenterIn: TFPoint;
Var
  Lc, Lb, La             : Double;
  cx, cy, bx, by, ax, ay : Double; 
  K1, K2                 : Double;
begin
  Lb := DistBC/DistAB;
  Lc := DistBC/DistAC;
 
  cx := (fx2+Lc*fx1)/(Lc+1);
  cy := (fy2+Lc*fy1)/(Lc+1);
 
  bx := (fx3+Lb*fx1)/(Lb+1);
  by := (fy3+Lb*fy1)/(Lb+1);
 
  if cx <> fx3 then K1 := (cy-fy3)/(cx-fx3) else K1 := 1e+96;
  if bx <> fx2 then K2 := (by-fy2)/(bx-fx2) else K2 := 1e+96;
 
  Result.x := (K1*fx3-K2*fx2+(fy2-fy3))/(K1-K2);
  if Result.x <> fx3 then
    Result.y := K1*(Result.x-fx3)+fy3
  else
    Result.y := K2*(Result.x-fx2)+fy2;
end;
 
 
function TTriangle.GetCenterOut: TFPoint;
Var ma, mb : Double;  //  коэффициенты наклона линий
begin
  if fx2 <> fx1 then ma := (fy2-fy1)/(fx2-fx1) else ma := 1e95;
  if fx3 <> fx2 then mb := (fy3-fy2)/(fx3-fx2) else mb := 1e95;
  Result.x := (ma*mb*(fy1-fy3) + mb*(fx1+fx2) - 
               ma*(fx2+fx3))/(2*(mb-ma));
  if ma <> 0 then
    Result.y :=  -1/ma*(Result.x - (fx1+fx2)/2) + (fy1+fy2)/2
  else
    Result.y :=  -1/mb*(Result.x - (fx2+fx3)/2) + (fy2+fy3)/2;
end;
 
 
function TTriangle.GetDistAB: Double;
begin
  Result := Dist ( fx1, fy1, fx2, fy2);
end;
 
 
function TTriangle.GetDistAC: Double;
begin
  Result := Dist ( fx1, fy1, fx3, fy3);
end;
 
 
function TTriangle.GetDistBC: Double;
begin
  Result := Dist ( fx2, fy2, fx3, fy3);
end;
 
 
function TTriangle.GetPerimeter: Double;
begin
  Result := DistAB + DistBC + DistAC;
end;
 
 
function TTriangle.GetRadiusIn: Double;
begin
  if not PointsInLine then
    Result := 2 * Area / Perimeter;
end;
 
 
function TTriangle.GetRadiusOut: Double;
begin
  if not PointsInLine then
    Result := (DistAB*DistBC*DistAC)/(4*Area);
end;
 
 
function TTriangle.PointsInLine: Boolean;
Var a : double;
begin
  Result := false;
  a := fx1*fy2+fx2*fy3+fx3*fy1-fx3*fy2-fx2*fy1-fx1*fy3;
  if abs(a - 1e-20) < 1e-19 then
    Result := true;
end;

Пример использования класса для задачи "Как найти площадь треугольника, заданного длинами сторон a=10, b=12, c=11?"

procedure TForm1.Button1Click(Sender: TObject);
Var T: TTriangle;
begin
   T := TTriangle.Create( 10, 12, 11);
   showmessage( FloatToStr( T.Area));
end;

Пример использования класса для задачи "Как найти периметр треугольника, заданного координатами вершин A(0,0), B(1,0), C(1,1)?"

procedure TForm1.Button1Click(Sender: TObject);
Var T: TTriangle;
begin
   T := TTriangle.Create( 0, 0, 1, 0, 1, 1);
   showmessage(FloatToStr( T.Perimeter));
end;

Отправил JamesSmaro Сб, 03/14/2020 - 19:18

order levitra now http://levph24.com - buy levitra online legal order viagra online

Отправил Fifapyday Сб, 03/14/2020 - 17:31

generic viagra walmart http://levph24.com - levitra online levitra sale online

Отправил FuenceMup Сб, 03/14/2020 - 17:17

order cheap online levitra http://viaph24.com - generic viagra 100mg viagra for women for sale in the uk

Отправил ZacharyHef Пнд, 03/09/2020 - 12:36

where can i order cialis ed pills buy viagra online no rx

Отправил ClarkGok Пнд, 03/09/2020 - 12:24

buy levitra bayer viagra cialis mail order pharmacy
cheap viagra or cialis http://vclph24.com how to use cialis pills

Отправил ViotteLot Пнд, 03/09/2020 - 10:24

viagra cheap next day delivery generic viagra safest place to buy cialis
cheap viagra sale online http://vclph24.com viagra without prescription cheap viagra buy cheap viagra mexico

Отправил Fleripek Пнд, 03/09/2020 - 08:12

cheapest generic levitra online http://tadmedz.com - cialis vs levitra order cialis cheap

Отправил Gustavolig Пнд, 03/09/2020 - 03:30

buy cialis from canadian pharmacy ed pills viagra sale online
buy generic levitra from canada http://vclph24.com viagra sale ottawa generic viagra levitra cheap canada

Отправил ViotteLot Пнд, 03/09/2020 - 03:00

herbal viagra for sale ed drugs online buy cialis australia online
viagra online usa http://vclph24.com cheapest way to buy cialis cheap drugs cheap viagra without rx

Отправил ClarkGok Пнд, 03/09/2020 - 01:09

cialis sale london cheap drugs buy viagra boots
cheapest place to get cialis http://vclph24.com cheap viagra in london

Отправил ZacharyHef Вс, 03/08/2020 - 23:10

buy viagra super active online buy viagra online buy viagra toronto canada

Отправил ViotteLot Чт, 03/05/2020 - 18:15

cheap levitra professional buy viagra can buy cialis over counter usa
how to buy a viagra http://vclph24.com where to buy levitra buy generic viagra mail order cialis from canada

Отправил JamesSmaro Чт, 03/05/2020 - 18:07

how to buy cialis in australia buy generic viagra how buy viagra online
buy cialis mastercard http://vclph24.com is there a generic cialis available? viagra online where to buy viagra generic

Отправил ClarkGok Чт, 03/05/2020 - 17:45

cheapest cialis new zealand cheap drugs how to cut a cialis pill in half
cialis canada http://vclph24.com buy levitra overnight

Отправил ZacharyHef Чт, 03/05/2020 - 16:06

buy viagra no prescription canada viagra online levitra for sale online

Отправил FuenceMup Чт, 03/05/2020 - 15:21

viagra buy online no prescription http://vclph24.com can i buy viagra in japan cheap viagra cheap viagra alternative

Отправил JamesSmaro Чт, 03/05/2020 - 12:17

buying cialis in london generic viagra cialis super active sale
generic viagra buy canada http://vclph24.com cuanto sale el viagra en farmacias buy generic viagra buy cialis johor bahru

Отправил ClarkGok Чт, 03/05/2020 - 12:03

buy cialis vs viagra buy viagra online how to buy viagra in india
order viagra sample http://vclph24.com viagra cheap fast

Отправил ViotteLot Чт, 03/05/2020 - 10:51

wholesale cost of cialis buy viagra online viagra buy dubai
buy cialis generic online cheap http://vclph24.com cheap viagra london buy viagra online cheapest generic viagra and cialis

Отправил ZacharyHef Чт, 03/05/2020 - 09:34

canadian cialis vcl buy viagra online from uk

Отправил FuenceMup Чт, 03/05/2020 - 06:49

buy cialis without doctor prescription http://vclph24.com use of cialis pills viagra online cialis discount coupon

Отправил Gustavolig Чт, 03/05/2020 - 06:26

buy levitra cheap online buy viagra viagra cheap fast
generic levitra cheapest prices http://vclph24.com viagra sale in india viagra online buy cialis online germany

Отправил ClarkGok Чт, 03/05/2020 - 06:25

buy cialis online discount buy viagra online discount generic cialis 20mg
cialis cheapest lowest price http://vclph24.com order a viagra online

Отправил JamesSmaro Чт, 03/05/2020 - 05:51

cheap generic viagra in uk buy viagra levitra discount canada
buy viagra cialis online canada http://vclph24.com cheap cialis soft buy cheap levitra online viagra cheap overnight

Отправил ViotteLot Чт, 03/05/2020 - 03:36

non generic cialis sale ed drugs online buy cialis delhi
how to buy generic viagra online http://vclph24.com buy red viagra cheap drugs viagra sale singapore

Отправил ZacharyHef Чт, 03/05/2020 - 03:06

buy cialis mississauga generic viagra cheapest generic cialis uk

Отправил ClarkGok Чт, 03/05/2020 - 01:59

can i buy cialis in usa buy generic viagra best place to buy levitra online
mail order viagra online http://vclph24.com cialis buy cheap

Отправил ClarkGok Ср, 03/04/2020 - 22:05

order viagra professional buy viagra online discount viagra order
should you buy cialis online http://vclph24.com buy viagra express delivery

Отправил FuenceMup Ср, 03/04/2020 - 22:04

cheap viagra canadian pharmacy http://vclph24.com cheap viagra pharmacy buy generic viagra discount card for cialis

Отправил ViotteLot Ср, 03/04/2020 - 20:27

cheap viagra tablets sale viagra online cialis sale uk
viagra sale forum http://vclph24.com buy viagra online cheap ed pills cheap viagra 100mg

Отправил ZacharyHef Ср, 03/04/2020 - 19:58

can you buy cialis over the counter in usa cheap herbal viagra online viagra sale lloyds

Отправил ClarkGok Ср, 03/04/2020 - 17:46

viagra cialis pills can you buy viagra rite aid order viagra super active+
buy viagra from pfizer http://vclph24.com cialis over the counter 2019

Отправил Gustavolig Ср, 03/04/2020 - 17:31

cheap viagra online canada cheap drugs buy cialis las vegas
online viagra prescription http://vclph24.com cheap cialis pills cheap viagra where to buy generic cialis in canada

Отправил FuenceMup Ср, 03/04/2020 - 13:57

buy online viagra viagra http://vclph24.com buy viagra super active ed drugs online buy viagra quebec

Отправил ViotteLot Ср, 03/04/2020 - 13:31

order viagra now vcl viagra online uk cheapest
pink cialis pills http://vclph24.com buy cialis retail viagra online order viagra cialis

Отправил ZacharyHef Ср, 03/04/2020 - 12:58

cheap cialis with no prescription viagra levitra online cheap

Отправил ClarkGok Ср, 03/04/2020 - 12:43

cialis sale no prescription buy viagra online generic viagra pills
viagra cheap .com http://vclph24.com viagra and cialis for sale

Отправил JamesSmaro Ср, 03/04/2020 - 10:01

cialis discount prices buy cialis lilly where to buy levitra in canada
levitra pills for sale http://vclph24.com buy cheapest cialis cheap drugs discount generic cialis 20mg

Отправил ViotteLot Ср, 03/04/2020 - 06:25

viagra buy online no prescription uk ed pills order generic viagra no prescription
can cialis pills split http://vclph24.com buy cialis daily buy viagra can you split cialis pills in half

Отправил FuenceMup Ср, 03/04/2020 - 05:50

buy cialis viagra levitra http://vclph24.com take cialis pills cheap drugs do you need a prescription to buy levitra

Отправил ClarkGok Ср, 03/04/2020 - 05:49

viagra sale england buy generic viagra mail order cialis online
cheapest levitra generic http://vclph24.com buy viagra europe

Отправил ZacharyHef Ср, 03/04/2020 - 05:26

do not order mexican viagra buy viagra online viagra professional pills

Отправил Gustavolig Ср, 03/04/2020 - 05:05

cialis india buy viagra online cheap viagra pay with paypal
map html buy viagra http://vclph24.com order viagra united states generic cialis sale buy levitra pills online

Отправил JamesSmaro Ср, 03/04/2020 - 02:47

cheap cialis pills generic viagra cialis buy online
buy cialis no prescription canada http://vclph24.com viagra plus buy cheap viagra order levitra from canada

Отправил ClarkGok Втр, 03/03/2020 - 23:58

cheap viagra uk site viagra online discount cialis soft tabs
blood pressure pills and cialis http://vclph24.com cheap viagra sale online

Отправил ViotteLot Втр, 03/03/2020 - 23:54

viagra sale online canada ed pills buy professional viagra
where do buy viagra http://vclph24.com cheap cialis online uk vcl male enhancement pills cialis

Отправил ZacharyHef Втр, 03/03/2020 - 23:00

cheap viagra to buy online generic viagra buy viagra toronto canada

Отправил FuenceMup Втр, 03/03/2020 - 21:11

viagra sale durban http://vclph24.com can you buy viagra cvs cheap drugs buy viagra usa

Отправил JamesSmaro Втр, 03/03/2020 - 19:37

order cialis to canada vcl buy cialis for daily use
buy levitra pills http://vclph24.com can you buy cialis online no prescription vcl cialis online order canada

Отправил ClarkGok Втр, 03/03/2020 - 18:17

order levitra now viagra online cialis where to buy - malaysia
buy cheap cialis in australia http://vclph24.com cheap levitra prices generic vicodin xanax

Последние комментарии

Счетчики