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

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

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

can buy viagra uk or viagra buy online no prescription or cheap cialis online uk

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

how can i order cialis and cheap cialis forum and buy cialis online pharmacy

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

https://vclph24.com order cialis online overnight https://cialisxtl.com can you buy cialis uk https://canpharmb3.com

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

https://viagrawithoutdoctorspres.com cialis buy in canada https://tadmedz.com viagra buy online usa https://canadianpharmacystorm.com

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

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

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

experience research cheap viagra and order levitra professional oo and buy generic cialis online

Отправил Georgesmope Ср, 04/08/2020 - 07:43

buy cialis daily online https://alexa24ph.com - viagra on line levitra sale walmart

Отправил Fifapyday Ср, 04/08/2020 - 05:41

cheap kamagra cialis https://aralenph.com - buy alaren generic buy levitra with dapoxetine
cialis discount offers https://hydroxychloroquine24.com - hydroxychloroquine 200 mg price in india buy viagra online canada no prescription
buy cialis online cheap https://alexa24ph.com - viagra cheap-viagra.co.uk

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

order viagra from canada https://aralenph.com - buy alaren generic viagra sale sydney
where can i buy viagra in london https://tadal24ph.com - buy cialis viagra sale singapore
buy cheap cialis usa visa https://zithazi.com - zithromax online buy cialis dubai

Отправил Georgesmope Ср, 04/08/2020 - 02:13

buy cialis brand name https://zithazi.com - cheap zithromax how to buy viagra online

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

buy cialis online with prescription https://tadal24ph.com - cialis coupon canadian pharmacy cheap cialis

Отправил outwamout Втр, 04/07/2020 - 20:54

how can i order viagra online https://alexa24ph.com - real viagra without a doctor prescription best buy for levitra
cheap viagra online india https://kaletra24.com - kaletra generic buy viagra cialis canada
where to buy cialis https://zithazi.com - zithromax buy viagra cialis or levitra

Отправил Georgesmope Втр, 04/07/2020 - 20:45

viagra buy usa https://kaletra24.com - buy kaletra online viagra sale durban

Отправил Walterpag Втр, 04/07/2020 - 19:10

where can i buy viagra in las vegas https://aralenph.com - aralen buy viagra from china
buy name brand cialis online https://zithazi.com - zithromax generic viagra sale online
cheap cialis tablets https://tadal24ph.com - generic tadalafil buy authentic cialis

Отправил Fifapyday Втр, 04/07/2020 - 19:07

levitra buy singapore https://hydroxychloroquine24.com - generic plaquenil viagra cheap alternatives
generic viagra mail order https://zithazi.com - zithromax cheap viagra jelly uk
discount viagra professional https://aralenph.com - generic alaren herbal viagra sale

Отправил FuenceMup Втр, 04/07/2020 - 18:40

cheap alternative to viagra https://alexa24ph.com - cheap viagra buy cialis legally online

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

viagra buy online australia https://tadal24ph.com - cialis cialis buy online cheap

Отправил outwamout Втр, 04/07/2020 - 11:53

can you really buy viagra online https://zithazi.com - buy Azithromycin how to buy generic cialis
cialis tablete za zene https://alexa24ph.com - viagra without a doctor prescription buy cialis from usa
viagra over the counter usa 2019 https://hydroxychloroquine24.com - plaquenil generic for cialis

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

pills like cialis https://hydroxychloroquine24.com - plaquenil for sale where can i buy cialis online in australia

Отправил Walterpag Втр, 04/07/2020 - 11:16

viagra cheap discount https://aralenph.com - alaren price cheap mexico viagra
viagra buy cheap https://alexa24ph.com - viagra pills real viagra sale uk
viagra sale bangkok https://zithazi.com - cheap zithromax cheap cialis generic india

Отправил Georgesmope Втр, 04/07/2020 - 09:43

cheap viagra overnight delivery https://tadal24ph.com - cialis coupon how do i buy levitra

Отправил Fifapyday Втр, 04/07/2020 - 08:36

viagra cialis buy online https://kaletra24.com - cheap kaletra cheap viagra + web.uinteramericana.edu
buy real viagra no prescription https://zithazi.com - cheap zithromax viagra cheap .com
cialis super active cheap https://alexa24ph.com - viagra without doctor prescription cialis 20 mg price walmart

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

generic levitra for sale https://hydroxychloroquine24.com - plaquenil for sale buy viagra in uk

Отправил Georgesmope Втр, 04/07/2020 - 04:15

where can i buy cialis soft tabs https://zithazi.com - buy Azithromycin buy cialis at boots

Отправил Walterpag Втр, 04/07/2020 - 03:24

buy cialis amsterdam https://alexa24ph.com - cheap viagra viagra sale pfizer
viagra-cheap.org https://aralenph.com - cheap chloroquine buy generic levitra online
buy cialis manila https://tadal24ph.com - tadalafil order cialis online with prescription

Отправил outwamout Втр, 04/07/2020 - 02:56

cheap viagra from india https://kaletra24.com - Ritonavir 50 mg and Lopinavir 200 mg buy online prescription viagra without
cheap levitra online https://aralenph.com - buy alaren generic cialis online
buy viagra high street https://alexa24ph.com - generic viagra 100mg cheapest generic cialis uk

Отправил Georgesmope Пнд, 04/06/2020 - 22:45

cialis c5 pill https://tadal24ph.com - cialis online viagra sale qatar

Отправил Fifapyday Пнд, 04/06/2020 - 22:06

cheap viagra generic canada https://hydroxychloroquine24.com - hydroxychloroquine 200 mg price in india generic cialis wholesale
cialis canada cheapest https://zithazi.com - zithromax buy real cialis uk
cheap viagra for sale https://alexa24ph.com - viagra online cialis pills color

Отправил FuenceMup Пнд, 04/06/2020 - 21:12

www.cheap-generic-viagra.co.uk/ https://alexa24ph.com - cheap viagra how do i order viagra online

Отправил Walterpag Пнд, 04/06/2020 - 19:30

order cialis phone https://aralenph.com - cheap chloroquine cheapest levitra australia
cheap generic cialis canada https://zithazi.com - zithromax Azithromycin buy viagra in the usa
viagra sale forum https://kaletra24.com - cheap kaletra order viagra discreetly

Отправил outwamout Пнд, 04/06/2020 - 18:02

order generic cialis online https://hydroxychloroquine24.com - plaquenil generic cialis break pills
order levitra online https://aralenph.com - aralen viagra sale australia
cheapest cialis in new zealand https://alexa24ph.com - generic viagra 100mg generic cialis discount

Отправил Georgesmope Пнд, 04/06/2020 - 17:16

cialis pills dosage https://hydroxychloroquine24.com - buy hydroxychloroquine online order viagra online usa

Отправил FuenceMup Пнд, 04/06/2020 - 14:01

viagra discount https://aralenph.com - alaren online levitra super active cheap us

Отправил Walterpag Пнд, 04/06/2020 - 11:34

best place buy cialis line https://alexa24ph.com - viagra on line order generic cialis online canada
generic name for viagra https://kaletra24.com - kaletra generic cheapest levitra super active oo
cheap cialis 10 mg https://hydroxychloroquine24.com - plaquenil buy cialis in the uk

Отправил Fifapyday Пнд, 04/06/2020 - 11:16

mail order viagra generic https://tadal24ph.com - cialis 20 mg best price discount cialis soft tabs
cheapest cialis internet https://alexa24ph.com - viagra samples from pfizer buy cialis online in australia
viagra online pills https://aralenph.com - buy chloroquine online how to buy cialis online

Отправил Georgesmope Пнд, 04/06/2020 - 11:02

very cheap generic viagra https://tadal24ph.com - generic cialis cheapest cialis pharmacy comparison

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

cialis cheapest lowest price https://tadal24ph.com - buy cialis buy viagra in poland
buy.viagra.com https://zithazi.com - buy zithromax order brand name viagra online
order generic cialis india https://alexa24ph.com - buy viagra viagra generic buy

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

order viagra ireland https://alexa24ph.com - viagra without doctor prescription levitra buy germany

Отправил Georgesmope Пнд, 04/06/2020 - 04:26

buy generic levitra uk https://alexa24ph.com - buy viagra cialis liquid for sale

Отправил Walterpag Пнд, 04/06/2020 - 03:43

buy cialis australia online https://kaletra24.com - kaletra generic viagra sale over counter
buy viagra soho https://tadal24ph.com - tadalafil buy levitra with dapoxetine
buy cialis without prescriptions https://zithazi.com - zithromax online order viagra paypal

Отправил outwamout Пнд, 04/06/2020 - 00:17

cheap generic viagra in uk https://hydroxychloroquine24.com - buy hydroxychloroquine online buying cialis online from canada
how to order generic viagra online https://kaletra24.com - Ritonavir buy cheap cialis from india
viagra sale fast shipping https://alexa24ph.com - viagra online buy levitra 10mg

Отправил Fifapyday Вс, 04/05/2020 - 23:56

buy levitra online with prescription https://alexa24ph.com - sildenafil cialis pills cut half
where can i buy cialis or viagra on line https://kaletra24.com - kaletra how to buy generic viagra online
cheapest generic levitra online https://zithazi.com - Azithromycin online order cialis usa

Отправил FuenceMup Вс, 04/05/2020 - 23:47

cheapest cialis new zealand https://aralenph.com - buy alaren cheapest viagra super active

Отправил Georgesmope Вс, 04/05/2020 - 21:56

cialis and sleeping pills https://tadal24ph.com - generic cialis viagra tablets sale

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

levitra cheap online https://zithazi.com - buy Azithromycin what does cialis pills look like
buy cheap viagra uk online https://tadal24ph.com - cialis 20 mg best price cialis buy london
can you buy cialis uk https://aralenph.com - alaren online cialis for sale no prescription

Отправил FuenceMup Вс, 04/05/2020 - 16:42

buy viagra over counter uk https://hydroxychloroquine24.com - buy hydroxychloroquine online cheap viagra uk

Отправил outwamout Вс, 04/05/2020 - 15:32

generic cialis online buy https://zithazi.com - buy zithromax cheap cialis generic no prescription
order cheap cialis online https://aralenph.com - buy alaren generic buy levitra cheap
pfizer viagra cheap prices https://hydroxychloroquine24.com - plaquenil buy cialis tadalafil

Отправил Georgesmope Вс, 04/05/2020 - 15:25

where can i buy viagra in manila https://aralenph.com - buy alaren generic buy cialis cheap prices fast delivery

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

cheap viagra uk next day delivery https://hydroxychloroquine24.com - plaquenil generic small order cialis
buy viagra costa rica https://aralenph.com - buy alaren generic order viagra thailand
viagra sale manila https://tadal24ph.com - п»їcialis viagra professional 100 mg pills

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

home page home page https://zithazi.com - buy zithromax buy generic cialis online in usa
buy black cialis online https://tadal24ph.com - cialis cost levitra buy online uk
how to get cheap cialis https://aralenph.com - buy alaren is mail order viagra legal

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

  • 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

Счетчики