1 -- Copyright 2021 Free Software Foundation, Inc.
3 -- This program is free software; you can redistribute it and/or modify
4 -- it under the terms of the GNU General Public License as published by
5 -- the Free Software Foundation; either version 3 of the License, or
6 -- (at your option) any later version.
8 -- This program is distributed in the hope that it will be useful,
9 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
10 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 -- GNU General Public License for more details.
13 -- You should have received a copy of the GNU General Public License
14 -- along with this program. If not, see <http://www.gnu.org/licenses/>.
16 package body Twovecs is
18 function Pt (X, Y : My_Integer) return Twovec is
23 function "+" (P0, P1 : Twovec) return Twovec is
25 return Twovec' (P0.X + P1.X, P0.Y + P1.Y);
28 function "-" (P0, P1 : Twovec) return Twovec is
30 return Twovec' (P0.X - P1.X, P0.Y - P1.Y);
33 function "*" (P0, P1 : Twovec) return Twovec is
35 return Twovec' (P0.X * P1.X, P0.Y * P1.Y);
38 function "/" (P0, P1 : Twovec) return Twovec is
40 return Twovec' (P0.X / P1.X, P0.Y / P1.Y);
43 function "mod" (P0, P1 : Twovec) return Twovec is
45 -- Make sure we get a different answer than "-".
46 return Twovec' (17, 18);
49 function "rem" (P0, P1 : Twovec) return Twovec is
51 -- Make sure we get a different answer than "-".
52 return Twovec' (38, 39);
55 function "**" (P0, P1 : Twovec) return Twovec is
57 -- It just has to do something recognizable.
58 return Twovec' (20 * P0.X + P1.X, 20 * P0.Y + P1.Y);
61 function "<" (P0, P1 : Twovec) return Boolean is
63 return P0.X < P1.X and then P0.Y < P1.Y;
66 function "<=" (P0, P1 : Twovec) return Boolean is
68 return P0.X <= P1.X and then P0.Y <= P1.Y;
71 function ">" (P0, P1 : Twovec) return Boolean is
73 return P0.X > P1.X and then P0.Y > P1.Y;
76 function ">=" (P0, P1 : Twovec) return Boolean is
78 return P0.X >= P1.X and then P0.Y >= P1.Y;
81 function "=" (P0, P1 : Twovec) return Boolean is
83 return P0.X = P1.X and then P0.Y = P1.Y;
86 function "and" (P0, P1 : Twovec) return Twovec is
88 return Twovec' (P0.X and P1.X, P0.Y and P1.Y);
91 function "or" (P0, P1 : Twovec) return Twovec is
93 return Twovec' (P0.X or P1.X, P0.Y or P1.Y);
96 function "xor" (P0, P1 : Twovec) return Twovec is
98 return Twovec' (P0.X xor P1.X, P0.Y xor P1.Y);
101 function "&" (P0, P1 : Twovec) return Twovec is
103 -- It just has to do something recognizable.
104 return Twovec' (10 * P0.X + P1.X, 10 * P0.Y + P1.Y);
107 function "abs" (P0 : Twovec) return Twovec is
109 return Twovec' (abs (P0.X), abs (P0.Y));
112 function "not" (P0 : Twovec) return Twovec is
114 return Twovec' (not (P0.X), not (P0.Y));
117 function "+" (P0 : Twovec) return Twovec is
119 -- It just has to do something recognizable.
120 return Twovec' (+ (P0.Y), + (P0.X));
123 function "-" (P0 : Twovec) return Twovec is
125 return Twovec' (- (P0.X), - (P0.Y));
128 procedure Do_Nothing (P : Twovec) is