Показать сообщение отдельно
  #4  
Старый 22.05.2010, 19:05
Аватар для TemnbluAngel
TemnbluAngel TemnbluAngel вне форума
Прохожий
 
Регистрация: 22.05.2010
Сообщения: 4
Репутация: 10
Сообщение

Не претендуя на элегантность решения, ввиду "написания на быструю руку", могу предложить следующее:

Код:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Image1: TImage;
    Label3: TLabel;
    Label4: TLabel;
    Button5: TButton;
    Button6: TButton;
    Label5: TLabel;
    Label6: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Label7: TLabel;
    Label8: TLabel;
    procedure Button6Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}



procedure TForm1.Button6Click(Sender: TObject);
begin
close;
end;

procedure vvod(Ed1,ed2:Tedit; var r,u:real);
var
dx,dy:real;
begin
dx:=StrToFloat(Ed1.text);
dy:=StrToFloat(Ed2.text);
r:=Hypot(dx,dy); //аналог r:=sqrt(sqr(dx)+sqr(dy));
u:=round(arctan(dy/dx)*180/pi);
end;

procedure vyvod (r,u:real; var l1,l2,l3,l4:Tlabel);
begin
L1.caption:=L1.caption+FloatToStr(r);
L2.caption:=L2.caption+FloatToStr(u);
L3.caption:=L3.caption+FloatToStr(r)+'*cos('+FloatToStr(u)+')';
L4.caption:=L4.caption+FloatToStr(r)+'*sin('+FloatToStr(u)+')';
end;

procedure TForm1.Button5Click(Sender: TObject);
var
r1,u1:real;
begin
Label3.caption:='r=';
Label6.caption:='u=';
Label7.caption:='x=';
Label8.caption:='y=';
vvod(Edit1,edit2,r1,u1);
vyvod (r1,u1,label3,label6, label7, label8);
end;

end.

Резюмируя, замечу, что u - это всегда острый угол ввиду того, что он рассматривается как тангенс положительного направления к оси Ох.

SOFT.rar
Ответить с цитированием