unit divers;
(* ***** BEGIN LICENSE BLOCK *****
* Copyright (C) 2004 Durand Emmanuel
* Copyright (C) 2004 Burgel Eric
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Contact :
* filters@edurand.com
* filters@burgel.com
*
* ***** END LICENSE BLOCK ***** *)
{
edurand (filters@edurand.com)
eburgel (filters@burgel.com)
}
interface
uses
image;
function getRotatedPoint(inPoint,Center:TFPoint; AngleR:Single) : TFPoint;
function fpoint(x,y:Integer) : TFPoint; overload;
function fpoint(x,y:Single) : TFPoint; overload;
procedure smoothIt(var h : Array of Single; smooth : Integer) ;
implementation
function getRotatedPoint(inPoint,Center:TFPoint; AngleR:Single) : TFPoint;
begin
Result.x:=Cos(AngleR)*(inPoint.x-Center.x)-Sin(AngleR)*(inPoint.y-Center.y)+Center.x;
Result.y:=Cos(AngleR)*(inPoint.y-Center.y)+Sin(AngleR)*(inPoint.x-Center.x)+Center.y;
end;
function fpoint(x,y:Integer) : TFPoint;
begin
Result.x:=x;
Result.y:=y;
end;
function fpoint(x,y:Single) : TFPoint;
begin
Result.x:=x;
Result.y:=y;
end;
procedure smoothIt(var h : Array of Single; smooth : Integer) ;
Var
h2 : Array of Extended ;
size : Integer ;
i, n, index : Integer ;
Begin
size := Length(h) ;
setLength(h2, size) ;
for n := 1 to smooth do Begin
for i:=0 to size-1 do begin
// Central point
h2[i] := h[i]/2 ;
// right point
index := (i+1) ;
if index >= size then dec(index,size) ;
h2[i] := h2[i] + h[index] / 4 ;
// left point
index := i-1;
if index <0 then inc(index, size) ;
h2[i] := h2[i] + h[index] / 4 ;
end ;
for i:=0 to size-1 do h[i] := h2[i] ;
End ;
End ;
end.