| 1 |
(* Copyright (C) 2005-2025 Free Software Foundation, Inc. *) |
| 2 |
(* This file is part of Chisel. |
| 3 |
|
| 4 |
Chisel is free software; you can redistribute it and/or modify it under |
| 5 |
the terms of the GNU General Public License as published by the Free |
| 6 |
Software Foundation; either version 3, or (at your option) any later |
| 7 |
version. |
| 8 |
|
| 9 |
Chisel is distributed in the hope that it will be useful, but WITHOUT ANY |
| 10 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 |
for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License along |
| 15 |
with gm2; see the file COPYING. If not, write to the Free Software |
| 16 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *) |
| 17 |
DEFINITION MODULE Geometry ; |
| 18 |
|
| 19 |
(* |
| 20 |
Title : Geometry |
| 21 |
Author : Gaius Mulley |
| 22 |
Date : 20/8/88 |
| 23 |
LastEdit : 20/8/88 |
| 24 |
System : LOGITECH MODULA-2/86 |
| 25 |
Description: Defines some commonly used geometrical functions. |
| 26 |
*) |
| 27 |
|
| 28 |
EXPORT QUALIFIED IsSubLine, IsSubRange, IsIntersectingRange, |
| 29 |
IntersectionLength, IsPointOnLine, |
| 30 |
Abs, Min, Max, Swap ; |
| 31 |
|
| 32 |
|
| 33 |
(* |
| 34 |
IsSubLine - returns true if the range i1..i2 or j1..j2 are ranges |
| 35 |
of each other. |
| 36 |
*) |
| 37 |
|
| 38 |
PROCEDURE IsSubLine (i1, i2, j1, j2: CARDINAL) : BOOLEAN ; |
| 39 |
|
| 40 |
|
| 41 |
(* |
| 42 |
IsSubRange - returns true if i lies inbetween High and Low. |
| 43 |
*) |
| 44 |
|
| 45 |
PROCEDURE IsSubRange (Low, High, i: CARDINAL) : BOOLEAN ; |
| 46 |
|
| 47 |
|
| 48 |
(* |
| 49 |
IsIntersectingRange - returns true if the ranges i1..i2 j1..j2 |
| 50 |
overlap. |
| 51 |
*) |
| 52 |
|
| 53 |
PROCEDURE IsIntersectingRange (i1, i2, j1, j2: CARDINAL) : BOOLEAN ; |
| 54 |
|
| 55 |
|
| 56 |
(* |
| 57 |
IntersectionLength - returns the intersection length |
| 58 |
of the overlapping ranges i1..i2 j1..j2. |
| 59 |
*) |
| 60 |
|
| 61 |
PROCEDURE IntersectionLength (i1, i2, j1, j2: CARDINAL) : CARDINAL ; |
| 62 |
|
| 63 |
|
| 64 |
(* |
| 65 |
IsPointOnLine - returns true if point x, y is on line (x1, y1) , (x2, y2) |
| 66 |
*) |
| 67 |
|
| 68 |
PROCEDURE IsPointOnLine (x, y: CARDINAL; x1, y1, x2, y2: CARDINAL) : BOOLEAN ; |
| 69 |
|
| 70 |
|
| 71 |
(* |
| 72 |
Max - returns the largest cardinal number from i and j. |
| 73 |
*) |
| 74 |
|
| 75 |
PROCEDURE Max (i, j: CARDINAL) : CARDINAL ; |
| 76 |
|
| 77 |
|
| 78 |
(* |
| 79 |
Min - returns the smallest cardinal number from i and j. |
| 80 |
*) |
| 81 |
|
| 82 |
PROCEDURE Min (i, j: CARDINAL) : CARDINAL ; |
| 83 |
|
| 84 |
|
| 85 |
(* |
| 86 |
Abs - returns the difference between i and j. |
| 87 |
*) |
| 88 |
|
| 89 |
PROCEDURE Abs (i, j: CARDINAL) : CARDINAL ; |
| 90 |
|
| 91 |
|
| 92 |
(* |
| 93 |
Swap - swaps two cardinal numbers i and j. |
| 94 |
*) |
| 95 |
|
| 96 |
PROCEDURE Swap (VAR i, j: CARDINAL) ; |
| 97 |
|
| 98 |
|
| 99 |
END Geometry. |