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

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

Отправил Chestertearo Вс, 02/02/2020 - 12:53

cialis pills from india cialis average wholesale price viagra sale next day delivery

Отправил JohnnyKak Вс, 02/02/2020 - 12:17

best place to buy cialis uk buy cialis amazon where do i buy cheap viagra

Отправил Robertincef Вс, 02/02/2020 - 08:24

where do buy viagra buy cialis online canada pharmacy cialis generic name

Отправил JamesDeK Вс, 02/02/2020 - 07:14

is there a generic cialis available? viagra buy shop order viagra in uk

Отправил Georgelic Вс, 02/02/2020 - 05:12

viagra sale melbourne acheter cialis discount viagra online canadian pharmacy

Отправил Shawnvub Вс, 02/02/2020 - 03:32

viagra sale amazon https://edmedz.com how to buy levitra in canada

Отправил Chestertearo Вс, 02/02/2020 - 01:31

buy viagra online eu cialis pills expire cheapest price for levitra

Отправил JohnnyKak Вс, 02/02/2020 - 00:51

viagra buy switzerland buy viagra generic canada discount viagra or cialis

Отправил JamesDeK Сб, 02/01/2020 - 22:05

cialis discount card buy red viagra cheap cialis forum

Отправил Robertincef Сб, 02/01/2020 - 18:46

can i buy cialis in usa cuanto sale el viagra en farmacias buy now viagra cialis

Отправил Georgelic Сб, 02/01/2020 - 18:16

safe place to buy levitra cheap cialis sydney cialis for sale in toronto

Отправил Chestertearo Сб, 02/01/2020 - 13:21

cheap viagra 50 mg cialis for sale in the us cheap/discount cialis

Отправил JamesDeK Сб, 02/01/2020 - 12:57

mail order viagra legitimate buy viagra brisbane buy viagra tablets

Отправил JohnnyKak Сб, 02/01/2020 - 12:36

cheap viagra now mastercard order viagra thailand cheapest cialis canada .com

Отправил Robertincef Сб, 02/01/2020 - 11:59

viagra pills for sale buy levitra dapoxetine cuanto sale el cialis

Отправил Georgelic Сб, 02/01/2020 - 09:19

buy viagra malaysia online cheap viagra from india cialis online cheap canada

Отправил Robertincef Сб, 02/01/2020 - 05:33

cheapest cialis online uk order brand viagra online legit cheap viagra

Отправил Bryangepay Сб, 02/01/2020 - 04:45

can you buy cialis over the counter https://edmedz.com cheap viagra china

Отправил JamesDeK Сб, 02/01/2020 - 04:08

buy viagra australia viagra sale australia viagra from canada

Отправил JohnnyKak Сб, 02/01/2020 - 01:03

cheap cialis viagra cheap generic viagra co uk kamagra oral jelly 100mg buy viagra vietnam

Отправил Robertincef Сб, 02/01/2020 - 00:35

buy cialis uk next day delivery cheap cialis canadian pharmacy buy levitra europe

Отправил Georgelic Сб, 02/01/2020 - 00:12

best place to order viagra online buy viagra cialis levitra cheap levitra super active oo

Отправил Robertincef Пт, 01/31/2020 - 19:44

how to buy cialis no prescription where can i buy viagra in la viagra buy in london

Отправил JamesDeK Пт, 01/31/2020 - 18:53

buy cialis manila viagra for women for sale in the uk viagra buy cyprus

Отправил Bryangepay Пт, 01/31/2020 - 16:28

order viagra with mastercard https://edmedz.com cheap alternative to viagra

Отправил Robertincef Пт, 01/31/2020 - 15:03

how to buy cialis with a prescription cheap viagra soft buy viagra with mastercard

Отправил Chestertearo Пт, 01/31/2020 - 14:13

where to buy cialis online cialis 5mg price buy online levitra in usa

Отправил JohnnyKak Пт, 01/31/2020 - 13:19

cialis pills color how to buy generic cialis online is it illegal to order viagra online

Отправил Georgelic Пт, 01/31/2020 - 12:41

viagra sale manila cheap viagra bangkok buy viagra uk tesco

Отправил Robertincef Пт, 01/31/2020 - 10:41

buy viagra zurich viagra sale brisbane how to buy levitra in canada

Отправил JamesDeK Пт, 01/31/2020 - 09:51

order levitra online cheap mexico viagra viagra sale qatar

Отправил Robertincef Пт, 01/31/2020 - 05:52

cheap viagra new zealand buy cheap cialis australia how to buy cialis no prescription

Отправил Bryangepay Пт, 01/31/2020 - 04:13

genuine cialis sale https://edmedz.com buy viagra professional online

Отправил Chestertearo Пт, 01/31/2020 - 02:50

buy cialis vs viagra viagra buy bangalore buy viagra real

Отправил JamesDeK Пт, 01/31/2020 - 02:01

where to buy cialis in usa canada levitra buy online cialis pills sale uk

Отправил JohnnyKak Пт, 01/31/2020 - 01:50

mail order viagra order viagra cialis buy generic cialis online canada

Отправил Georgelic Пт, 01/31/2020 - 01:39

online viagra buy viagra soho how to buy cialis online in australia

Отправил Robertincef Пт, 01/31/2020 - 00:58

buy viagra cheap uk cheap 2.5 mg cialis cialis tablet nedir

Отправил Robertincef Чт, 01/30/2020 - 20:28

cialis for sale in manila viagra cost per pill cheap generic levitra online

Отправил JamesDeK Чт, 01/30/2020 - 18:38

can i buy viagra in boots best place to buy viagra yahoo buy cialis online canadian pharmacy

Отправил Robertincef Чт, 01/30/2020 - 15:48

buy cheap viagra uk online cuanto sale viagra en argentina buy real cialis online

Отправил Chestertearo Чт, 01/30/2020 - 15:38

quality cheap meds pills cialis cheap levitra australia buy cialis england

Отправил Bryangepay Чт, 01/30/2020 - 15:14

meds sale levitra https://edmedz.com cialis cheap india

Отправил JohnnyKak Чт, 01/30/2020 - 14:30

mexican viagra levitra buy online no prescription cialis professional sale

Отправил Georgelic Чт, 01/30/2020 - 14:10

how to order cialis online buy discount cialis viagra

Отправил Robertincef Чт, 01/30/2020 - 11:18

cheap cialis viagra online red pill blue pill viagra discount viagra

Отправил JamesDeK Чт, 01/30/2020 - 11:15

levitra a prix discount can you buy generic cialis usa levitra buy

Отправил Williamses Ср, 01/29/2020 - 11:59

family pharmacy generic viagra prices
best canadian online pharmacy http://genericvgrmax.com# how does cialis work cialis going generic in 2019 in us
viagra generic availability http://cialisxtl.com/#v walmart online pharmacy viagra coupons from pfizer
viagra canadian pharmacy vipps approved http://viagrawithoutdoctorspres.com#

Отправил Williamses Ср, 01/29/2020 - 05:53

real cialis online with paypal trial samples of viagra
how much does cialis cost http://canadianpharmacystorm.com/#0 generic cialis black 800mg how much does cialis cost
pharmacy express http://cialisxtl.com/#a canadian pharmacy viagra reviews cheapest viagra
can you have multiple orgasms with cialis http://genericvgrmax.com#

Отправил Williamses Втр, 01/28/2020 - 23:44

what is cialis used for viagra online
canadian compounding pharmacy http://viagrawithoutdoctorspres.com# how to take viagra for maximum effect generic viagra prices
generic cialis at walgreens pharmacy http://genericvgrmax.com# canadian pharmacy online reviews interactions for cialis
viagra pill http://cialisxtl.com/#s

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

Счетчики