IPB
ЛогинПароль:

> ВНИМАНИЕ!

Прежде чем задать вопрос, смотрите FAQ.
Рекомендуем загрузить DRKB.

Наладить общение поможет, если вы подпишитесь по почте на новые темы в этом форуме.

 
 Ответить  Открыть новую тему 
> График с проверкой попадпния, Делфи.Графика
сообщение
Сообщение #1


Пионер
**

Группа: Пользователи
Сообщений: 65
Пол: Мужской

Репутация: -  0  +


Ребят помогите пожалуйста...никак не могу проверить на попадпние в заданную область...вот код...график начертил..на форме только image и lable1:
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Image1: TImage;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
with image1.Canvas do
begin
pen.Color := clBlack;
brush.Color := clRed;

moveTo(200,50);
lineTo(200, 350);
moveTo(50,200);
LineTo(350, 200);

moveTo(200,60);
lineTo(340,200);
lineTo(200,340);

arc(60,60,340,340,200,50,201,350);

floodFill(199,199, clBlack, fsBorder);
floodFill(201,199, clBlack, fsBorder);
floodFill(199,201, clBlack, fsBorder);
floodFill(201,201, clBlack, fsBorder);
textout(190,205,'0');
textout(70,205,'-1');
textout(307,205,'1');
textout(190,65,'1');
textout(190,315,'-1');
end;
end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (x<0) and (x*x+y*y<?)or (x>0) and ((x+y)<?) then
form1.Label1.Caption:='Принадлежит' else
form1.Label1.Caption:='Не принадлежит';
end;

end.


Никак не могу понять с чем нужно сравнивать...заранее спасибо.
 Оффлайн  Профиль  PM 
 К началу страницы 
+ Ответить 
сообщение
Сообщение #2


Гость






Так что-ли?

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
X := X - 200; Y := Y - 200;
If (X < 0) and (sqr(X)+sqr(Y) < sqr(139)) or
(X >= 0) and (140 - X - abs(Y) > 0) Then form1.Label1.Caption:= 'Принадлежит'
else form1.Label1.Caption := 'Не принадлежит';
end;
 К началу страницы 
+ Ответить 
сообщение
Сообщение #3


Пионер
**

Группа: Пользователи
Сообщений: 65
Пол: Мужской

Репутация: -  0  +


Ага..огромное спасибо
 Оффлайн  Профиль  PM 
 К началу страницы 
+ Ответить 
сообщение
Сообщение #4


Пионер
**

Группа: Пользователи
Сообщений: 65
Пол: Мужской

Репутация: -  0  +


unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Image1: TImage;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Label2: TLabel;
Label3: TLabel;
RadioButton1: TRadioButton;
Label4: TLabel;
Edit3: TEdit;
procedure FormCreate(Sender: TObject);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
with image1.Canvas do
begin
pen.Color := clBlack;
brush.Color := clAqua;

moveTo(200,50);
lineTo(200, 350);
moveTo(50,200);
LineTo(350, 200);

moveTo(200,60);
lineTo(340,200);
lineTo(200,340);

arc(60,60,340,340,200,50,201,350);

floodFill(199,199, clBlack, fsBorder);
floodFill(201,199, clBlack, fsBorder);
floodFill(199,201, clBlack, fsBorder);
floodFill(201,201, clBlack, fsBorder);
textout(190,205,'0');
textout(70,205,'-1');
textout(307,205,'1');
textout(190,65,'1');
textout(190,315,'-1');
end;


end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
X := X - 200; Y := Y - 200;
If (X < 0) and (sqr(X)+sqr(Y) < sqr(139)) or
(X >= 0) and (140 - X - abs(Y) > 0) Then form1.Label1.Caption:= 'Ïðèíàäëåæèò'
else form1.Label1.Caption := 'Íå ïðèíàäëåæèò';
end;

procedure TForm1.Button2Click(Sender: TObject);
Var
x1,y1,y,x:real;
vivod: string;
x0:real;
begin
if RadioButton1.Checked then
x:=0.112
else x:=StrToFloat(Edit1.Text);
x0:=x;
y:=Arctan(x/sqrt(1-sqrt(x)))+exp(2);
vivod:='ïðè õ= ' + FloatToStrF(x0,ffGeneral,4,2) + ' y = ' + FloatToStrF(y,ffGeneral,4,2);
Label4.Caption:=vivod;
radiobutton1.checked := false;
Edit1.Text:='';
end;

procedure TForm1.Button1Click(Sender: TObject);
var
l,m:real;
begin
if (form1.Edit2.text<>'')and(form1.Edit3.text<>'') then
l:= strtofloat(form1.Edit1.text);
m:=strtofloat(form1.Edit2.text);
if (l<0)and (sqr(l)+sqr(m)<1) and (l>0) and (abs(l+m)<1) then
form1.Label1.Caption:='Ïðèíàäëåæèò' else
form1.Label1.Caption:='Íå ïðèíàäëåæèò';
end;

end.




Теперь вот такая проблемка,процедура клика по 1-ой кнопке проверяет попадание в область в результате введения значений с клавиатуры(но она ругается и я не пойму в чем ошибка).
Клик по 2-ой кнопке отвечает за ввода значения X с клавиатуры,а выдается рассчет Y.(Также ругается+ошибка такаяже как в попадании)
Помогите пожалуйста..заранее очень благодарен
 Оффлайн  Профиль  PM 
 К началу страницы 
+ Ответить 
сообщение
Сообщение #5


Пионер
**

Группа: Пользователи
Сообщений: 65
Пол: Мужской

Репутация: -  0  +


Вот исправил 2 процедуры,но всеравно считает ток целые числа.Ребят помогите плиз..завтра сдавать,а я не могу допереть...Заранее Огромное спасибо
procedure TForm1.Button2Click(Sender: TObject);
Var
x1,y1,y,x:real;
vivod: string;
x0:real;
begin
if RadioButton1.Checked=true then
x:=0.112
else
x:=StrToFloat(Edit1.Text);
x0:=x;
y:=Arctan(x/sqrt(1-sqr(x)))+exp(2);
vivod:='ïðè õ= ' + FloatToStrF(x0,ffFixed,4,2) + ' y = ' + FloatToStrF(y,ffFixed,4,2);
Label4.Caption:=vivod;
radiobutton1.checked := false;
Edit1.Text:='';
end;

procedure TForm1.Button1Click(Sender: TObject);
var
l,m:real;
begin
if (form1.Edit2.text<>'')and(form1.Edit3.text<>'') then
begin
l:=strtofloat(form1.Edit2.text);
m:=strtofloat(form1.Edit3.text);
end;
if (l<0) and (sqr(trunc(l))+sqr(trunc(m))<1) and (l>0) and (abs(l+m)<1) then
form1.Label1.Caption:='Ïðèíàäëåæèò' else
form1.Label1.Caption:='Íå ïðèíàäëåæèò';
end;

 Оффлайн  Профиль  PM 
 К началу страницы 
+ Ответить 
сообщение
Сообщение #6


Пионер
**

Группа: Пользователи
Сообщений: 65
Пол: Мужской

Репутация: -  0  +


Все..программу написал,все работает...если кому пригодится,выкладываю:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, TeEngine, Series, TeeProcs, Chart;

type
TForm1 = class(TForm)
Image1: TImage;
Label1: TLabel;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Chart1: TChart;
Series1: TLineSeries;
Button3: TButton;
PrintDialog1: TPrintDialog;
Button4: TButton;
Button5: TButton;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
procedure FormCreate(Sender: TObject);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
with image1.Canvas do
begin
pen.Color := clBlack;
brush.Color := clAqua;

moveTo(200,50);
lineTo(200, 350);
moveTo(50,200);
LineTo(350, 200);

moveTo(200,60);
lineTo(340,200);
lineTo(200,340);

arc(60,60,340,340,200,50,201,350);

floodFill(199,199, clBlack, fsBorder);
floodFill(201,199, clBlack, fsBorder);
floodFill(199,201, clBlack, fsBorder);
floodFill(201,201, clBlack, fsBorder);
textout(190,205,'0');
textout(70,205,'-1');
textout(307,205,'1');
textout(190,65,'1');
textout(190,315,'-1');
end;

end;

procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
X := X - 200; Y := Y - 200;
If (X < 0) and (sqr(X)+sqr(Y) < sqr(139)) or
(X >= 0) and (140 - X - abs(Y) > 0) Then form1.Label1.Caption:= 'Принадлежит'
else form1.Label1.Caption := 'Не принадлежит';
end;

procedure TForm1.Button2Click(Sender: TObject);
var
y,x:real;
begin
try
x:=strtofloat(Edit1.Text);
y:=Arctan(x/sqrt(1-sqr(x)))+exp(2);
Label4.Caption:='Y= '+floattostr(y);
except
on EConvertError do
begin
ShowMessage('Введите число!'+#13+'При записи дробного числа используйте запятую.');
exit;
end;
end;
if Label4.Caption<>'' then Button3.Enabled:=True;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
l,m:real;
begin
if (form1.Edit2.text<>'')and(form1.Edit3.text<>'') then
begin
l:=strtofloat(form1.Edit2.text);
m:=strtofloat(form1.Edit3.text);
end;
if (l<=0) and ((l*l+m*m)<=1) or (l>=0) and (abs(l+m)<=1) then
form1.Label1.Caption:='Принадлежит' else
form1.Label1.Caption:='Не принадлежит';
end;

procedure TForm1.Button3Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to 100 do
Series1.AddXY(0.01*Pi*i,Arctan((0.01*Pi*i)/sqr(1-(0.01*Pi*i)*(0.01*Pi*i)))+(0.01*Pi*i)*(0.01*Pi*i));
end;


procedure TForm1.Button4Click(Sender: TObject);
begin
Form2.Image1.Picture.Bitmap:=GetFormImage;
Form2.Showmodal;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if PrintDialog1.Execute then Form1.Print;
end;

end.

 Оффлайн  Профиль  PM 
 К началу страницы 
+ Ответить 

 Ответить  Открыть новую тему 
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 





- Текстовая версия 28.03.2024 22:28
500Gb HDD, 6Gb RAM, 2 Cores, 7 EUR в месяц — такие хостинги правда бывают
Связь с администрацией: bu_gen в домене octagram.name