Janilabo

Untitled

Aug 5th, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.53 KB | None | 0 0
  1. function SqEuclidean(pt1,pt2:TPoint): Double;
  2. var
  3.   dx,dy: Integer;
  4. begin
  5.   dx := pt1.x - pt2.x;
  6.   dy := pt1.y - pt2.y;
  7.   Result := dx*dx + dy*dy;
  8. end;
  9.  
  10. function Euclidean(pt1,pt2:TPoint): Double;
  11. begin
  12.   Result := Sqrt(pow((pt1.x - pt2.x),2) + pow((pt1.y - pt2.y),2));
  13. end;
  14.  
  15. var
  16.   a, b: TPoint;
  17.  
  18. begin
  19.   a := Point(44, 55);
  20.   b := Point(13, 16);
  21.   WriteLn('Distance: ' + ToStr(Distance(a.X, a.Y, b.X, b.Y)));
  22.   WriteLn('SqEuclidean: ' + ToStr(SqEuclidean(a, b)));
  23.   WriteLn('Euclidean: ' + ToStr(Euclidean(a, b)));
  24. end.
Advertisement
Add Comment
Please, Sign In to add comment