-
Notifications
You must be signed in to change notification settings - Fork 1
/
geom.pas
47 lines (33 loc) · 821 Bytes
/
geom.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
unit geom;
interface
function distance(x,y,x1,y1:double):double; overload;
function sign(a:double):integer;
function normalize_angle(angle:double):double;
function normalize_angle_rot(angle:double):double;
implementation
function distance(x,y,x1,y1:double):double;
var dx,dy:double;
begin
dx:=x1-x;
dy:=y1-y;
Result:=sqrt(dx*dx+dy*dy);
end;
function sign(a:double):integer;
begin
if a>0 then result:=1 else
if a<0 then result:=-1
else result:=0
end;
function normalize_angle(angle:double):double;
begin
while angle>2*Pi do angle:=angle-2*Pi;
while angle<0 do angle:=angle+2*Pi;
Result:=angle;
end;
function normalize_angle_rot(angle:double):double;
begin
angle:=normalize_angle(angle);
if angle>Pi then angle:=Pi-angle;
Result:=angle;
end;
end.