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

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

Отправил DavidBeilt Пнд, 04/13/2020 - 11:31

how to order viagra and cheap generic cialis australia and cheaper viagra cialis levitra

Отправил Lloydnuaks Пнд, 04/13/2020 - 11:21

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

Отправил unfoleror Пнд, 04/13/2020 - 09:09

viagra sale cyprus and buy levitra online with prescription and is there a generic viagra

Отправил Neriderma Пнд, 04/13/2020 - 08:45

https://viagrawithoutdoctorspres.com buy cialis ebay https://cialisxtl.com viagra ice cream go sale selfridges https://canadianpharmacystorm.com

Отправил morhailia Пнд, 04/13/2020 - 08:42

cheap viagra wholesale or discount viagra for sale or the cheapest generic cialis

Отправил Boappyzep Пнд, 04/13/2020 - 08:19

https://vclph24.com cheapest genuine cialis https://cialisfavdrug.com cialis sale online australia https://canadianpharmacystorm.com

Отправил Fifapyday Пнд, 04/13/2020 - 07:46

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

Отправил Fifapyday Пнд, 04/13/2020 - 07:17

https://vclph24.com buy levitra online australia https://cialisxtl.com cialis cheap canada https://onlinepharmacyero.com

Отправил Georgeorani Пнд, 04/13/2020 - 06:08

https://viagrawithoutdoctorspres.com do you need a prescription to buy levitra https://tadmedz.com can buy viagra vietnam https://onlinepharmacyero.com

Отправил Fleripek Пнд, 04/13/2020 - 05:32

buy viagra toronto or order viagra internet or is there a generic cialis available in the us

Отправил DavidBeilt Пнд, 04/13/2020 - 04:18

buy levitra australia and real viagra for sale and cheap cialis from india

Отправил Lloydnuaks Пнд, 04/13/2020 - 04:14

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

Отправил Georgeorani Пнд, 04/13/2020 - 00:44

https://viagrawithoutdoctorspres.com viagra cheap real https://tadmedz.com buy cialis au https://onlinepharmacyero.com

Отправил morhailia Пнд, 04/13/2020 - 00:44

order viagra in europe or cheap viagra brisbane or cheapest viagra soft tabs

Отправил Neriderma Пнд, 04/13/2020 - 00:01

https://vclph24.com buy viagra delhi https://cialisxtl.com buy cialis prescription online https://onlinepharmacyero.com

Отправил Boappyzep Вс, 04/12/2020 - 21:24

https://viagrawithoutdoctorspres.com cialis on sale https://cialisxtl.com otc viagra https://canadianpharmacystorm.com

Отправил Lloydnuaks Вс, 04/12/2020 - 21:14

https://viagrawithoutdoctorspres.com ; https://cialisxtl.com ; https://onlinepharmacyero.com

Отправил DavidBeilt Вс, 04/12/2020 - 21:09

buy cialis eli lilly and where can i buy viagra in la and buy genuine cialis

Отправил Fleripek Вс, 04/12/2020 - 20:52

buy cialis us pharmacy or cheap levitra canadian pharmacy or viagra super active pill

Отправил Georgeorani Вс, 04/12/2020 - 19:37

https://vclph24.com cialis a prix discount https://cialisxtl.com buy generic cialis online https://onlinepharmacyero.com

Отправил morhailia Вс, 04/12/2020 - 16:39

cheapest levitra australia or buy viagra and cialis or cheap levitra australia

Отправил unfoleror Вс, 04/12/2020 - 16:18

buy cialis brand online and buy cialis walmart and can you buy viagra in thailand

Отправил Neriderma Вс, 04/12/2020 - 15:02

https://viagrawithoutdoctorspres.com viagra professional 100mg pills https://cialisfavdrug.com discount prices on cialis https://onlinepharmacyero.com

Отправил Lloydnuaks Вс, 04/12/2020 - 14:33

https://vclph24.com ; https://cialisxtl.com ; https://onlinepharmacyero.com

Отправил DavidBeilt Вс, 04/12/2020 - 14:23

viagra buy forum and cialis cheapest lowest price and levitra for sale online

Отправил Georgeorani Вс, 04/12/2020 - 14:14

https://viagrawithoutdoctorspres.com cialis super active sale https://cialisxtl.com cheap viagra no rx https://canpharmb3.com

Отправил Fleripek Вс, 04/12/2020 - 11:57

cialis tablet yan etkileri or buy viagra jelly or cheap viagra without rx

Отправил Boappyzep Вс, 04/12/2020 - 11:09

https://viagrawithoutdoctorspres.com where can i buy viagra online yahoo https://tadmedz.com best place to order viagra online https://canadianpharmacystorm.com

Отправил Georgeorani Вс, 04/12/2020 - 09:00

https://viagrawithoutdoctorspres.com cialis pills color https://cialisxtl.com viagra buy in london https://onlinepharmacyero.com

Отправил DavidBeilt Вс, 04/12/2020 - 08:32

order viagra from mexico and cialis generic best price and how to get viagra

Отправил morhailia Вс, 04/12/2020 - 08:30

cuanto sale el viagra en farmacias or non prescription viagra or buy levitra online cheap

Отправил unfoleror Вс, 04/12/2020 - 08:29

buy cialis nz and buy cialis online canadian pharmacy and how much is viagra

Отправил Lloydnuaks Вс, 04/12/2020 - 07:36

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

Отправил Neriderma Вс, 04/12/2020 - 05:52

https://vclph24.com brand levitra for sale https://cialisfavdrug.com order cialis for daily use https://onlinepharmacyero.com

Отправил Georgeorani Вс, 04/12/2020 - 04:04

https://vclph24.com buy cialis online us pharmacy https://cialisfavdrug.com cialis discount https://onlinepharmacyero.com

Отправил Fleripek Вс, 04/12/2020 - 03:22

order viagra paypal or buy viagra gold or order a viagra online

Отправил DavidBeilt Вс, 04/12/2020 - 01:52

cheap viagra ireland and cheapest place to get cialis and buy generic levitra australia

Отправил Boappyzep Вс, 04/12/2020 - 00:34

https://vclph24.com buy cialis professional https://cialisfavdrug.com where to order viagra for women https://canadianpharmacystorm.com

Отправил unfoleror Вс, 04/12/2020 - 00:21

buy viagra in london and buy viagra hujagra 2011 and buy viagra online legit

Отправил morhailia Вс, 04/12/2020 - 00:17

the cheapest generic cialis or cialis buy uk or viagra without a doctor prescription canada

Отправил Lloydnuaks Вс, 04/12/2020 - 00:17

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

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

https://vclph24.com buy cialis super active https://cialisxtl.com buy discount cialis online https://canpharmb3.com

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

https://vclph24.com cheap viagra deals https://cialisfavdrug.com cheap viagra super force https://onlinepharmacyero.com

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

generic levitra for sale and buy cialis and viagra and buy cialis no prescription in uk

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

levitra professional cheapest or levitra professional sale or viagra cheap overnight

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

https://viagrawithoutdoctorspres.com best place buy cialis line https://tadmedz.com cheap cialis overnight https://canadianpharmacystorm.com

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

where can buy viagra and cheap viagra us and where to buy the cheapest cialis

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

https://viagrawithoutdoctorspres.com ; https://cialisxtl.com ; https://onlinepharmacyero.com

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

buy cialis online in australia or generic cialis cheapest price or meds sale levitra

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

https://vclph24.com generic viagra buy canada https://cialisxtl.com the cheapest generic cialis https://onlinepharmacyero.com

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

  • vitality ed pills cure for ed or natural ed medications treatment for erectile dysfunction or how to get amoxicillin can i buy amoxicillin over the counter or prednisone 20 mg tablets coupon prednisone 5mg coupon or vacuum pump for ed ed pills for sale
  • erectile dysfunction medication comparison of ed drugs ed cures that work otc ed pills https://canadianpharmacyvikky.com real viagra without a doctor prescription usa ed aids buy prescription drugs online without herbal remedies for ed
  • ed medications over the counter canadian pharmacy vikky best ed drugs new erectile dysfunction treatment https://canadianpharmacyvikky.com ed pills online

Счетчики