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

Для расчета основных параметров треугольника (таких как: периметр, площадь, длины сторон, углы, координаты, радиусы вписанной и описанной окружностей, а также координаты их центров) можно воспользоваться следующим классом 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;

Отправил Walterpag Втр, 03/31/2020 - 22:08

order cialis online canada http://kaletra24.com - buy kaletra cheap viagra blog
order viagra legally http://aralenph.com - alaren online order viagra prescription
generic for cialis http://tadal24ph.com - cialis 20 mg best price cheap viagra bulk

Отправил Fleripek Втр, 03/31/2020 - 21:23

viagra for sale over the counter http://kaletra24.com - buy kaletra buy viagra generic canada

Отправил FuenceMup Втр, 03/31/2020 - 18:49

how can i order cialis http://zithazi.com - zithromax online cheap viagra uk buy

Отправил JeremyBat Втр, 03/31/2020 - 17:49

how to order a viagra http://kaletra24.com - buy generic kaletra order generic viagra overnight
can cialis pills cut http://tadal24ph.com - cialis coupon brand levitra for sale
cialis pill http://aralenph.com - chloroquine cialis canada

Отправил Georgesmope Втр, 03/31/2020 - 15:22

purchase cheap cialis soft tabs http://tadal24ph.com - cialis how can i order viagra online

Отправил Walterpag Втр, 03/31/2020 - 14:22

can you buy cialis online in canada http://aralenph.com - buy alaren buy cialis 5mg
buy cialis black online http://alexa24ph.com - generic viagra 100mg buy viagra london
buy cialis canada paypal http://hydroxychloroquine24.com - buy hydroxychloroquine online best place to order levitra

Отправил outwamout Втр, 03/31/2020 - 13:53

can cialis pills be cut http://aralenph.com - buy alaren generic cialis discount canada
where can i buy viagra online yahoo answers http://tadal24ph.com - cheap cialis cialis discount australia
cheap generic levitra http://alexa24ph.com - cost of viagra order levitra now

Отправил Fleripek Втр, 03/31/2020 - 13:44

cheapest 20 mg cialis http://kaletra24.com - kaletra viagra canada

Отправил JeremyBat Втр, 03/31/2020 - 13:27

real viagra sale online http://zithazi.com - Azithromycin online order viagra with mastercard
п»їviagra sale jamaica http://alexa24ph.com - cheap viagra buy cialis cheap prices fast delivery
order viagra by mail http://aralenph.com - cheap chloroquine cialis for sale online

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

safe order cialis canada http://zithazi.com - generic zithromax cheap viagra paypal payment

Отправил Georgesmope Втр, 03/31/2020 - 08:47

order generic viagra cialis http://hydroxychloroquine24.com - plaquenil generic red cialis pills

Отправил JeremyBat Втр, 03/31/2020 - 08:45

buy cialis and levitra http://aralenph.com - chloroquine viagra sale karachi
п»їcheapest place to buy generic cialis http://alexa24ph.com - viagra viagra for sale uk
cheap viagra alternatives uk http://tadal24ph.com - cialis cost buy levitra 20 mg online

Отправил Walterpag Втр, 03/31/2020 - 06:38

cheapest place to buy levitra http://alexa24ph.com - viagra for sale buy viagra legally uk
buy levitra china http://tadal24ph.com - cheap cialis buy viagra wholesale
cialis daily use discount http://zithazi.com - cheap zithromax buy levitra cheap

Отправил Fleripek Втр, 03/31/2020 - 06:09

buy viagra online forum http://kaletra24.com - buy kaletra buy viagra online paypal

Отправил outwamout Втр, 03/31/2020 - 05:12

order viagra discreetly http://aralenph.com - cheap chloroquine cheap viagra sale
herbal viagra sale http://alexa24ph.com - generic viagra generic cialis 2019
buy generic cialis in usa http://tadal24ph.com - cialis generic viagra for sale atlanta

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

cialis buy uk online http://kaletra24.com - buy generic kaletra buy viagra generic

Отправил JeremyBat Втр, 03/31/2020 - 04:11

cialis for sale in philippines http://kaletra24.com - Ritonavir can you buy viagra online
cheapest cialis on the internet http://zithazi.com - zithromax Azithromycin can you buy levitra over the counter
buy viagra online new zealand http://hydroxychloroquine24.com - plaquenil discount generic levitra

Отправил Fifapyday Втр, 03/31/2020 - 02:59

buy cialis singapore http://hydroxychloroquine24.com - plaquenil for sale viagra online cheap
where is the best place to buy cialis online http://alexa24ph.com - viagra online where to buy viagra generic
best buy for levitra http://kaletra24.com - buy kaletra online buy red viagra

Отправил Georgesmope Втр, 03/31/2020 - 01:37

buy cialis mexico http://zithazi.com - zithromax can cialis pills be cut

Отправил JeremyBat Пнд, 03/30/2020 - 23:46

п»їcheap quick viagra http://alexa24ph.com - how long for viagra to take effect where can i buy a viagra
buy viagra yahoo http://zithazi.com - zithromax levitra for sale in uk
genuine viagra for sale http://aralenph.com - buy alaren cialis to buy us

Отправил Walterpag Пнд, 03/30/2020 - 22:50

viagra sale singapore http://tadal24ph.com - generic cialis buy viagra
cvs viagra http://hydroxychloroquine24.com - plaquenil for sale where can i order cialis online
buy cialis 20mg online http://kaletra24.com - kaletra cheap viagra uk no prescription

Отправил Fleripek Пнд, 03/30/2020 - 22:37

is it legal to order viagra from canadian http://kaletra24.com - kaletra price cialis pills sale canada

Отправил FuenceMup Пнд, 03/30/2020 - 21:58

cialis buy online cheap http://kaletra24.com - Lopinavir how to buy generic viagra online

Отправил outwamout Пнд, 03/30/2020 - 20:38

where to buy cialis online no prescription http://zithazi.com - Azithromycin cialis for sale uk
legit cheap viagra http://kaletra24.com - buy kaletra cheap viagra bulk
viagra sale vancouver bc http://tadal24ph.com - cialis generic buy cialis brand

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

levitra sales http://tadal24ph.com - cialis online buy viagra professional
cheap viagra brand http://aralenph.com - alaren online cialis at discount price
п»їbuy cialis brand http://alexa24ph.com - viagra pills cheap-generic-viagra erfahrung

Отправил Georgesmope Пнд, 03/30/2020 - 18:33

buy real cialis http://tadal24ph.com - buy cialis buy levitra online in canada

Отправил Walterpag Пнд, 03/30/2020 - 15:07

cheap viagra no rx http://tadal24ph.com - tadalafil viagra super active for sale&39;
viagra super force 100mg 100mg pills http://aralenph.com - chloroquine buy viagra online cheap uk
buy viagra online japan http://kaletra24.com - buy generic kaletra viagra sale pakistan

Отправил Fleripek Пнд, 03/30/2020 - 15:00

cialis cheap online pharmacy http://kaletra24.com - cheap kaletra where can i buy real viagra online

Отправил FuenceMup Пнд, 03/30/2020 - 15:00

generic viagra without a doctor prescription http://aralenph.com - aralen cialis buy uk online

Отправил Fifapyday Пнд, 03/30/2020 - 14:38

order viagra with paypal http://kaletra24.com - Lopinavir viagra on sale
cheap viagra 100mg http://zithazi.com - Azithromycin buy levitra mastercard
is there a generic cialis available in the us http://tadal24ph.com - generic tadalafil can you buy viagra boots

Отправил JeremyBat Пнд, 03/30/2020 - 14:36

buy viagra rio janeiro http://tadal24ph.com - cialis 20 mg best price order cialis no prescription canada
buying cialis online uk http://aralenph.com - aralen buy cialis soft online
best place buy generic cialis http://zithazi.com - buy Azithromycin order cialis phone

Отправил outwamout Пнд, 03/30/2020 - 12:02

real cialis for sale http://tadal24ph.com - cialis buy cialis brand
legal to order viagra online http://kaletra24.com - buy generic kaletra canadian cialis
generic viagra cost http://alexa24ph.com - buy viagra cialis 20mg price

Отправил Georgesmope Пнд, 03/30/2020 - 11:41

buy viagra nz http://aralenph.com - buy chloroquine online cialis order uk

Отправил JeremyBat Пнд, 03/30/2020 - 08:58

п»їcheap viagra kamagra http://alexa24ph.com - sildenafil buy cialis
red pill blue pill viagra http://hydroxychloroquine24.com - buy plaquenil is it legal to buy cialis online in canada
cialis sale toronto http://zithazi.com - Azithromycin buy generic levitra online

Отправил FuenceMup Пнд, 03/30/2020 - 08:04

buy viagra bali http://alexa24ph.com - generic viagra buy cialis online canada paypal

Отправил Walterpag Пнд, 03/30/2020 - 07:25

viagra cheap alternatives http://tadal24ph.com - cheap cialis cialis online buy
order viagra thailand http://kaletra24.com - kaletra price viagra gel sale
mail order viagra usa http://hydroxychloroquine24.com - plaquenil for sale levitra for sale

Отправил Fleripek Пнд, 03/30/2020 - 05:35

can buy viagra rite aid http://kaletra24.com - Ritonavir 50 mg and Lopinavir 200 mg buy brand name cialis online

Отправил Georgesmope Пнд, 03/30/2020 - 05:27

buy cialis in europe http://alexa24ph.com - buy viagra cheapest cialis and viagra

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

order levitra canada http://zithazi.com - generic zithromax cheap viagra super active 100mg
is there a generic for viagra http://kaletra24.com - Lopinavir cheap cialis canada pharmacy
viagra sale edmonton http://tadal24ph.com - liquid cialis cheap brand name viagra

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

how to buy cialis no prescription http://aralenph.com - alaren price discount generic cialis canada
where can i buy viagra in la http://tadal24ph.com - cheap cialis otc cialis
buy cialis in the uk http://kaletra24.com - cheap kaletra viagra buy in usa

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

order levitra online uk http://aralenph.com - chloroquine buy cialis online no prescription usa
buy cialis walmart http://hydroxychloroquine24.com - buy plaquenil cheapest cialis internet
buy viagra from china http://kaletra24.com - buy kaletra how much is viagra

Отправил FuenceMup Пнд, 03/30/2020 - 01:05

buy cialis with no prescription http://tadal24ph.com - cialis cost real viagra sale online

Отправил Walterpag Вс, 03/29/2020 - 23:39

cheap viagra no prescription needed http://aralenph.com - cheap chloroquine buy cheap generic levitra
buy generic levitra australia http://zithazi.com - Azithromycin online cheap canadian cialis
order-cialis.com http://hydroxychloroquine24.com - plaquenil online brand name viagra sale

Отправил Georgesmope Вс, 03/29/2020 - 22:20

levitra buy http://alexa24ph.com - sildenafil order viagra online australia

Отправил JeremyBat Вс, 03/29/2020 - 21:42

order cialis online uk http://zithazi.com - zithromax buy viagra uk quick delivery
order cialis online with mastercard http://aralenph.com - cheap chloroquine buy viagra canada
cialis pills cut half http://kaletra24.com - buy generic kaletra cheap viagra melbourne

Отправил Fleripek Вс, 03/29/2020 - 20:05

best place to order cialis online http://kaletra24.com - kaletra price cheap viagra pills uk

Отправил outwamout Вс, 03/29/2020 - 18:53

can cialis pills be split in half http://zithazi.com - zithromax price viagra buy in australia
viagra buy china http://aralenph.com - cheap chloroquine buy cialis cheap prices fast delivery
cheapest genuine cialis http://alexa24ph.com - cheap viagra can cialis pills cut half

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

order levitra professional oo http://hydroxychloroquine24.com - generic plaquenil cheap cialis and levitra

Отправил Walterpag Вс, 03/29/2020 - 15:58

cheap cialis fast shipping http://alexa24ph.com - cheap viagra price of cialis
viagra sale in new zealand http://tadal24ph.com - generic cialis where to buy cialis online in uk
buy viagra uk only http://hydroxychloroquine24.com - buy hydroxychloroquine online viagra sale lloyds pharmacy

Отправил JeremyBat Вс, 03/29/2020 - 15:53

cialis and sleeping pills http://kaletra24.com - Lopinavir cheap levitra 20mg
cheapest cialis in new zealand http://aralenph.com - aralen cheap viagra in usa
cheap viagra at tesco http://tadal24ph.com - cialis 20 mg best price buy levitra us

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

Счетчики