This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/examples/lo/travellers/geographic2.lgt
vsc fd048651b6 Logtalk files
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@55 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2001-06-06 20:07:01 +00:00

69 lines
1.1 KiB
Plaintext

:- object(geographic(_OX, _OY)).
:- info([
authors is 'Paulo Moura',
version is 1.0,
date is 2000/4/22,
parnames is ['OX', 'OY'],
comment is '.',
source is 'Example adopted from the Francis G. McCabe L&O documentation.']).
:- public(less/2).
less(Town1, Town2):-
angle(Town1, Angle1),
angle(Town2, Angle2),
Angle1 < Angle2.
angle(Town, Angle) :-
Town::at(X, Y),
parameter(1, OX),
parameter(2, OY),
angle(X, Y, OX, OY, Angle).
angle(X, Y, OX, OY, Angle) :-
X > OX,
Y >= OY,
Angle is atan((Y-OY)/(X-OX)).
angle(X, Y, OX, OY, Angle) :-
X > OX,
Y < OY,
pi(Pi),
Angle is Pi + Pi - atan((OY-Y)/(X-OX)).
angle(X, Y, OX, OY, Angle) :-
X < OX,
Y >= OY,
pi(Pi),
Angle is Pi - atan((Y-OY)/(OX-X)).
angle(X, Y, OX, OY, Angle) :-
X < OX,
Y < OY,
pi(Pi),
Angle is Pi + atan((OY-Y)/(OX-X)).
angle(OX, Y, OX, OY, Angle) :-
Y > OY,
pi(Pi),
Angle is Pi / 2.
angle(OX, Y, OX, OY, Angle) :-
Y =< OY,
pi(Pi),
Angle is 1.5 * Pi.
pi(Pi) :-
Pi is 4.0*atan(1.0).
:- end_object.