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

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

Отправил Georgeorani Сб, 04/11/2020 - 12:17

https://viagrawithoutdoctorspres.com cialis pills pictures http://tadmedz.com viagra professional http://onlinepharmacyero.com

Отправил DavidBeilt Сб, 04/11/2020 - 11:59

best site to order cialis and viagra buy online canada and cialis usa buy

Отправил Fleripek Сб, 04/11/2020 - 09:32

buy cialis levitra and viagra or canadian pharmacy cheap cialis or viagra ice cream go sale selfridges

Отправил Neriderma Сб, 04/11/2020 - 09:15

https://viagrawithoutdoctorspres.com viagra sale no prescription http://cialisxtl.com cialis buy now http://onlinepharmacyero.com

Отправил unfoleror Сб, 04/11/2020 - 07:34

cheapest levitra uk and buy cialis in uk and buy levitra cheap

Отправил Lloydnuaks Сб, 04/11/2020 - 07:01

https://vclph24.com ; http://tadmedz.com ; https://canpharmb3.com

Отправил Georgeorani Сб, 04/11/2020 - 06:59

https://vclph24.com viagra cheap buy http://cialisxtl.com viagra online buying https://canadianpharmacystorm.com

Отправил DavidBeilt Сб, 04/11/2020 - 04:50

cialis pills used and cialis sale online australia and viagra buy uk

Отправил morhailia Сб, 04/11/2020 - 04:28

buy viagra russia or cialis pills from india or site es cheap viagra

Отправил Boappyzep Сб, 04/11/2020 - 03:23

https://vclph24.com cialis wholesale uk http://cialisxtl.com generic cialis 2019 https://canadianpharmacystorm.com

Отправил Georgeorani Сб, 04/11/2020 - 01:52

https://vclph24.com viagra canada https://cialisfavdrug.com can you split cialis pills in half http://onlinepharmacyero.com

Отправил Fleripek Сб, 04/11/2020 - 01:00

viagra sale shops or cheap generic viagra overnight delivery or cheap viagra uk buy

Отправил unfoleror Пт, 04/10/2020 - 23:01

buy cheap viagra uk online and cialis buy over counter and over the counter viagra cvs

Отправил Neriderma Пт, 04/10/2020 - 22:10

https://viagrawithoutdoctorspres.com cheap generic viagra http://cialisxtl.com order viagra online illegal https://canadianpharmacystorm.com

Отправил DavidBeilt Пт, 04/10/2020 - 22:09

cialis at a discount and generic viagra sale uk and order real viagra online

Отправил Lloydnuaks Пт, 04/10/2020 - 21:56

https://viagrawithoutdoctorspres.com ; https://cialisfavdrug.com ; https://canadianpharmacystorm.com

Отправил Georgeorani Пт, 04/10/2020 - 20:29

https://vclph24.com how to buy viagra at boots http://cialisxtl.com cialis buy now https://canpharmb3.com

Отправил morhailia Пт, 04/10/2020 - 18:22

buy viagra kamagra online or best place to buy generic levitra or viagra sale over counter

Отправил Boappyzep Пт, 04/10/2020 - 16:41

https://viagrawithoutdoctorspres.com viagra for sale winnipeg http://cialisxtl.com buy viagra johor https://canpharmb3.com

Отправил Fleripek Пт, 04/10/2020 - 16:09

where do they sale viagra or viagra sale nhs or viagra buy no prescription canada

Отправил Georgeorani Пт, 04/10/2020 - 15:26

https://vclph24.com where to buy cialis pills http://tadmedz.com buy levitra next day delivery https://canadianpharmacystorm.com

Отправил DavidBeilt Пт, 04/10/2020 - 15:08

order viagra safely online and buy viagra tablets and should buy cialis online

Отправил unfoleror Пт, 04/10/2020 - 15:03

order cialis mexico and order levitra and cheap viagra in nz

Отправил Lloydnuaks Пт, 04/10/2020 - 12:43

https://vclph24.com ; https://cialisfavdrug.com ; https://canpharmb3.com

Отправил Neriderma Пт, 04/10/2020 - 10:57

https://vclph24.com cialis buy us http://tadmedz.com viagra without a doctor prescription https://canpharmb3.com

Отправил Georgeorani Пт, 04/10/2020 - 10:06

https://vclph24.com levitra where to buy https://cialisfavdrug.com canadian pharmacy cialis https://canpharmb3.com

Отправил morhailia Пт, 04/10/2020 - 08:21

buy viagra kenya or buy cialis for cheap or viagra buy london

Отправил DavidBeilt Пт, 04/10/2020 - 08:07

cheap cialis with prescription and cheap cialis brand and can you buy cialis over counter us

Отправил Fleripek Пт, 04/10/2020 - 07:20

buy viagra in china or buy cheap viagra uk or cheap-generic-viagra.com

Отправил unfoleror Пт, 04/10/2020 - 07:13

buy viagra jet and cialis c20 pills and cheap viagra uk online

Отправил Boappyzep Пт, 04/10/2020 - 06:57

https://vclph24.com buy discount generic cialis http://cialisxtl.com buy viagra at cvs https://canadianpharmacystorm.com

Отправил Georgeorani Пт, 04/10/2020 - 04:51

https://viagrawithoutdoctorspres.com cialis cheap overnight https://cialisfavdrug.com buy cheap viagra and cialis https://canpharmb3.com

Отправил Williamhen Пт, 04/10/2020 - 04:11

https://vclph24.com ; https://cialisfavdrug.com ; http://onlinepharmacyero.com

Отправил Lloydnuaks Пт, 04/10/2020 - 03:20

https://viagrawithoutdoctorspres.com ; https://cialisfavdrug.com ; https://canpharmb3.com

Отправил DavidBeilt Пт, 04/10/2020 - 01:08

order viagra from canada online and order viagra new zealand and order cialis online in canada

Отправил Georgeorani Пт, 04/10/2020 - 00:11

https://viagrawithoutdoctorspres.com cheap viagra germany https://cialisfavdrug.com buy viagra uk forum http://onlinepharmacyero.com

Отправил unfoleror Чт, 04/09/2020 - 23:53

buy cheap cialis profile and order viagra cheap and viagra sale lloyds

Отправил Neriderma Чт, 04/09/2020 - 23:42

https://vclph24.com order cialis mail http://cialisxtl.com buy excel herbal viagra https://canadianpharmacystorm.com

Отправил morhailia Чт, 04/09/2020 - 22:24

cheap liquid viagra or generic viagra cheap online or buy levitra without rx

Отправил Boappyzep Чт, 04/09/2020 - 21:47

https://vclph24.com cheap viagra to canada http://tadmedz.com cialis coupons https://canadianpharmacystorm.com

Отправил Williamhen Чт, 04/09/2020 - 20:16

https://vclph24.com ; https://cialisfavdrug.com ; https://canpharmb3.com

Отправил DavidBeilt Чт, 04/09/2020 - 18:01

cheap viagra aust and order viagra from usa and viagra super active pill

Отправил Lloydnuaks Чт, 04/09/2020 - 17:56

https://viagrawithoutdoctorspres.com ; http://tadmedz.com ; https://canadianpharmacystorm.com

Отправил unfoleror Чт, 04/09/2020 - 16:29

buy red viagra and buy cialis dubai and can i buy cialis over the counter in usa

Отправил Georgeorani Чт, 04/09/2020 - 15:08

https://viagrawithoutdoctorspres.com cheap viagra levitra https://cialisfavdrug.com where to order viagra for women http://onlinepharmacyero.com

Отправил Neriderma Чт, 04/09/2020 - 12:43

https://viagrawithoutdoctorspres.com cialis pills for women http://tadmedz.com buy cialis one a day https://canpharmb3.com

Отправил Boappyzep Чт, 04/09/2020 - 12:36

https://viagrawithoutdoctorspres.com discount cialis and viagra http://cialisxtl.com buy viagra dominican republic https://canadianpharmacystorm.com

Отправил morhailia Чт, 04/09/2020 - 12:20

order viagra online safe or viagra from canada or buy cialis vietnam

Отправил Williamhen Чт, 04/09/2020 - 12:08

https://vclph24.com ; https://cialisfavdrug.com ; http://onlinepharmacyero.com

Отправил Fifapyday Чт, 04/09/2020 - 11:30

https://viagrawithoutdoctorspres.com ; http://tadmedz.com ; https://canpharmb3.com

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

  • cialis coupon code https://cialmen.com cialis 20 image cialis samples request cheap tadalafil cialis generic
  • generic cialis no doctor's prescription https://cialmen.com prices of cialis buy viagra cialis order cialis cialis and interaction with ibutinib
  • Guys just made a web-page for me, look at the link: https://beachbags-11.webself.net/ Tell me your credentials. Thank you.

Счетчики