jueves, 23 de abril de 2009

DIST. 2 PTO'S ESFERICOS

unit distancia entre dos ptos coord. esfericas;

interface

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

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit7: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
VAR a,b,c,d,e,f,x1,x2,y1,y2,z1,z2,dist:real;
begin
a:=0 ;
b:=0 ;
c:=0 ;
d:=0 ;
e:=0;
f:=0;
a:=strtofloat(edit1.Text);
b:=strtofloat(edit2.Text);
c:=strtofloat(edit3.Text);
d:=strtofloat(edit4.Text);
e:=strtofloat(edit5.Text);
f:=strtofloat(edit6.Text);

x1:=a*cos(pi*b/180)*cos(pi*c/180);
y1:=a*cos(pi*b/180)*sin(pi*c/180);
z1:=a*sin(pi*b/180);
x2:=d*cos(pi*e/180)*cos(pi*f/180);
y2:=d*cos(pi*e/180)*sin(pi*f/180);
z2:=d*sin(pi*e/180);
dist:=sqrt(sqr(x2-x1)+sqr(y2-y1)+sqr(y2-y1));
edit7.Text:=floattostr(dist);

end;

end.

No hay comentarios:

Publicar un comentario