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

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

Отправил puboblix Чт, 04/23/2020 - 04:50

homepage https://viagrawithoutdoctorspres.com cheap viagra overnight delivery

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

cheap viagra prices https://canadianpharmacystorm.com cialis pills uk

Отправил unfoleror Ср, 04/22/2020 - 10:43

buy levitra viagra online pharmacy cheap viagra uk

Отправил puboblix Ср, 04/22/2020 - 10:29

how to get cheap viagra canadian pharmacy online viagra sale online australia

Отправил unfoleror Ср, 04/22/2020 - 08:26

cheap cialis generic medications without a doctor's prescription cialis cheap prescription

Отправил puboblix Ср, 04/22/2020 - 07:11

buy levitra online in canada https://canadianpharmacystorm.com buy viagra jelly

Отправил unfoleror Ср, 04/22/2020 - 06:11

order viagra mastercard buy pain meds from mexico cuanto sale el viagra en la argentina

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

cheapest genuine cialis https://canadianpharmacystorm.com canadian pharmacy buy cialis professional

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

where to buy cialis in usa https://canadianpharmacystorm.com buy cialis johor bahru

Отправил unfoleror Ср, 04/22/2020 - 01:16

order levitra online canada https://canadianpharmacystorm.com generic viagra cheap shipping

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

buy viagra generic canadian pharmacy discount viagra sale

Отправил unfoleror Втр, 04/21/2020 - 22:40

order viagra cialis online canadian pharmacy viagra buy no prescription

Отправил puboblix Втр, 04/21/2020 - 22:22

cheap viagra no rx canadian pharmacy online when will viagra be generic

Отправил unfoleror Втр, 04/21/2020 - 19:57

can you really buy cialis online medicine without dr prescription viagra sale durban

Отправил puboblix Втр, 04/21/2020 - 19:35

buy cialis viagra canada buy pain meds from mexico levitra on sale

Отправил unfoleror Втр, 04/21/2020 - 17:36

how can i order cialis https://canadianpharmacystorm.com cheap cialis generic no prescription

Отправил puboblix Втр, 04/21/2020 - 16:33

cheapest viagra cialis levitra medicine without dr prescription cheapest cialis on the net

Отправил unfoleror Втр, 04/21/2020 - 15:05

do you have to be 18 to buy viagra how to get prescription drugs without doctor how to order viagra online safely

Отправил puboblix Втр, 04/21/2020 - 13:22

hard sale evolution viagra salesman https://canadianpharmacystorm.com order real cialis

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

cheap cialis without rx canadian pharmacy buy bayer levitra

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

how to buy cialis in toronto pain meds online without doctor prescription levitra pills for sale

Отправил puboblix Втр, 04/21/2020 - 09:59

where to buy levitra https://canadianpharmacystorm.com where to buy cialis in toronto canada

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

cheap viagra and cialis on line https://canadianpharmacystorm.com buy viagra in canada

Отправил puboblix Втр, 04/21/2020 - 06:45

cialis canada order pain meds without written prescription order cialis online uk

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

where to get viagra https://canadianpharmacystorm.com cheap levitra professional oo

Отправил puboblix Втр, 04/21/2020 - 03:16

cheapest cialis canada .com canadian pharmacy viagra cheap australia

Отправил unfoleror Втр, 04/21/2020 - 01:34

ac uk buy cialis https://canadianpharmacystorm.com viagra otc

Отправил puboblix Втр, 04/21/2020 - 00:24

cialis from canada https://canadianpharmacystorm.com order viagra men

Отправил unfoleror Пнд, 04/20/2020 - 22:51

viagra pill pain meds online without doctor prescription order viagra usa

Отправил puboblix Пнд, 04/20/2020 - 21:41

viagra online order pain meds without written prescription viagra professional pills

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

cheap non prescription cialis https://canadianpharmacystorm.com mail order levitra

Отправил puboblix Пнд, 04/20/2020 - 18:55

buy brand levitra online https://canadianpharmacystorm.com buy cheap cialis uk

Отправил unfoleror Пнд, 04/20/2020 - 17:35

order viagra tesco painkillers online with next day delivery cheap viagra cialis levitra

Отправил puboblix Пнд, 04/20/2020 - 15:48

cheap herbal viagra pills painkillers online with next day delivery viagra sale next day delivery

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

discount generic levitra medications without a doctor's prescription cheap cialis canada

Отправил puboblix Пнд, 04/20/2020 - 12:30

cheap viagra or cialis online pharmacy buy viagra in dubai

Отправил unfoleror Пнд, 04/20/2020 - 12:27

buy viagra tablets online buy pain meds from mexico buy cialis bangkok

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

viagra sale johannesburg pain meds without written prescription viagra sale ireland

Отправил puboblix Пнд, 04/20/2020 - 09:16

viagra buy south africa https://canadianpharmacystorm.com viagra cheap .com

Отправил unfoleror Пнд, 04/20/2020 - 06:53

levitra online sales buy pain meds from mexico cheap viagra tablets

Отправил puboblix Пнд, 04/20/2020 - 05:55

cheap viagra paypal how to get prescription drugs without doctor generic viagra walmart

Отправил JerryNoM Пнд, 04/20/2020 - 03:48

http://sophiestarrmarshall.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://gizmopromo.net/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://clearingsessions.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://pitchpak.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://guildmarketplace.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://www.aaavista.net/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://psychaceuticals.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://msf.cost-spec.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://regionpr.ru/r.php?go=http://cialisxtl.com
http://boxeldergrants.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://dechinadirecto.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://www.tusfamosasdesnudas.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://dianesimon.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://unityofeffort.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://moneyonereit.com/__media__/js/netsoltrademark.php?d=cialisxtl.com

Отправил morhailia Пнд, 04/20/2020 - 03:33

buy cialis online no prescription or buy viagra mexico or donde sale viagra

Отправил Henrytum Пнд, 04/20/2020 - 02:02

http://consumercreditupdates.net/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://i-podius.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://reykur.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://www.creativeofficespace.tv/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://diskencryptionhelpdesk.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://www.companynamesearch.co.uk/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://clairmetric.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://sesamestreetpreschools.org/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://rotanafilms.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://haber.mackolikler.com/link.php?url=https://viagrawithoutdoctorspres.com
http://godstriumph.org/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://blackberryvietnam.net/proxy.php?link=https://viagrawithoutdoctorspres.com
http://gagindustrial.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://www.astrodaily.net/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://haboob.net/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://mydeadpc.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://axiscontainer.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://cslreit.net/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://exclusivelyused.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://badgerplugco.net/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com

Отправил Neriderma Вс, 04/19/2020 - 23:39

https://viagrawithoutdoctorspres.com buy cialis online no rx https://cialisfavdrug.com can you buy cialis over counter usa https://canadianpharmacystorm.com

Отправил Ramonblisp Вс, 04/19/2020 - 23:17

how does viagra work and viagra pill and viagra pills and viagra prices and cialis vs viagra and revatio vs viagra and viagra substitute and viagra without doctor prescription and viagra generic and viagra online and viagra vs cialis vs levitra and 100mg viagra without a doctor prescription and sildenafil 20 mg vs viagra and viagra without a doctor prescription walmart and viagra erection after ejaculation

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

http://retail-wire.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://club.suntwins.com/link.php?url=http://cialisxtl.com
http://showdegoles.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://doi-consultants.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://www.allpaysites.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://david-weekley.org/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://eoalliance.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://lacombecrane.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://irishroads.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://trans-aid.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://content.lordsofporn.com/dynascroll/lpscrollsbn.php?whichsite=whorelore&sitencolor=ffffff&scrollspeed=2000&showheader=no&container=yes&headertxt=&bordercolor=000000&bgcolor=000000&bannersize=5-v&linkingcode=http://cialisxtl.com
http://noexchangefee.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://showersonline.com/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://mondrian.tv/__media__/js/netsoltrademark.php?d=cialisxtl.com
http://invisiblehandbook.com/__media__/js/netsoltrademark.php?d=cialisxtl.com

Отправил morhailia Вс, 04/19/2020 - 20:44

where to buy viagra online uk or cheap viagra soft or how to buy cheap viagra

Отправил Henrytum Вс, 04/19/2020 - 20:05

http://cerno-solutions.biz/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://berkshireofthetriadrealestate.net/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://gibson-ballet.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://webstergy.com.sg/fms/trackpromo.php?promo_id=49&url=https://viagrawithoutdoctorspres.com
http://mainedirectvaloans.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
https://www.auntminnieeurope.com/index.aspx?sec=log&url=https://viagrawithoutdoctorspres.com
http://goodhandyman.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://hemuscleme.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
https://mp3mp3.do.am/go?https://viagrawithoutdoctorspres.com
http://longspharmacy.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com&quot
http://journey2strength.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://riderenterprises.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://www.ladas.gr/pharma/getdata/redirect.aspx?url=https://viagrawithoutdoctorspres.com
http://ak2xtreme.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://weeklywantads.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://wolfpack-isr.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://autoloansnorthwest.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://saintlouisexaminer.com/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://amc-theaters.org/__media__/js/netsoltrademark.php?d=viagrawithoutdoctorspres.com
http://gorod-perm.ru/widgets/outside/?url=https://viagrawithoutdoctorspres.com

Отправил Neriderma Вс, 04/19/2020 - 16:20

https://vclph24.com can i buy cialis over the counter http://cialisxtl.com how to order cialis online http://onlinepharmacyero.com

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

  • 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.
  • Guys just made a website for me, look at the link: http://ternogradu0.bloguetechno.com/--29077808 Tell me your prescriptions. Thanks.

Счетчики