📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Math, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Panel1: TPanel;
Button2: TButton;
LabeledEdit1: TLabeledEdit;
LabeledEdit2: TLabeledEdit;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Splitter1: TSplitter;
procedure Button2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
fTPoint = record
x:Extended;
y:Extended;
end;
yTPoint = record
x,y,r:Extended;
end;
var
Form1: TForm1;
Num:integer;
pt:array[1..1024]of fTPoint;
yuanNum:integer;
yuan:array[1..1024] of yTPoint;
implementation
{$R *.dfm}
procedure Getit(x1,y1,x2,y2,x3,y3:Extended;var x,y,r:Extended);
begin
// center x
x := ((y3-y1)*(y2-y1)*(y2-y3)+(x1*x1-x2*x2)*(y2-y3)+(x2*x2-x3*x3)*(y2-y1))
/(2*((x1-x2)*(y2-y3)+(x2-x3)*(y2-y1)));
// center y
if y2-y1 <> 0 then
y := ((x1-x2)/(y2-y1)*(2*x-(x1+x2))+y1+y2)/2
else
y := ((x2-x3)/(y3-y2)*(2*x-(x2+x3))+y2+y3)/2;
r:=Power((x1-x)*(x1-x)+(y1-y)*(y1-y), 0.5)
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i,j,k,l:integer;
str0,str1,str2:string;
x,y,r:extended;
canuse:boolean;
begin
yuanNum:=0;
for i:=1 to Num do
for j:=i+1 to Num do
for k:=j+1 to Num do
begin
if (i<>j) and (i<>k) and (j<>k) then
if ((pt[i].y-pt[j].y)*(pt[j].x-pt[k].x)<>(pt[j].y-pt[k].y)*(pt[i].x-pt[j].x)) then
begin
Getit(pt[i].x,pt[i].y,pt[j].x,pt[j].y,pt[k].x,pt[k].y,x,y,r);
if yuanNum=0 then
begin
inc(yuanNum);
yuan[yuanNum].x:=x;
yuan[yuanNum].y:=y;
yuan[yuanNum].r:=r;
end
else
canuse:=true;
for l:=1 to yuanNum do
if (yuan[l].x =x) and (yuan[l].y =y) and (yuan[l].r =r) then canuse:=false;
if canuse then
begin
inc(yuanNum);
yuan[yuanNum].x:=x;
yuan[yuanNum].y:=y;
yuan[yuanNum].r:=r;
end;
end;
end;
memo2.Lines.Add('-------------------------------------------------');
for i:=1 to yuanNum do
memo2.Lines.Add(inttostr(i)+' ('+floattostr(yuan[i].x)+','+floattostr(yuan[i].y)+') r='+floattostr(yuan[i].r));
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Memo1.Lines.Add(Labelededit1.Text+','+Labelededit2.Text);
inc(Num);
pt[Num].x:=strtofloat(Labelededit1.Text);
pt[Num].y:=strtofloat(Labelededit2.Text);
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
Num:=0;
memo1.Lines.Clear;
Memo2.Lines.Clear;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -