(* Copyright (C) 1992, Digital Equipment Corporation *) (* All rights reserved. *) (* See the file COPYRIGHT for a full description. *) (* *) (* Last modified on Tue Jun 16 16:46:26 PDT 1992 by muller *) INTERFACE RealInterval; (* Pair of REALs [lo,hi) An "interval" is a pair of REALs "lo" and "hi" with lo <= hi. It is meant to represent the left-closed, right-open segment [lo,hi), i.e. the set of REAL points between lo (included) and hi (excluded). Note: there are many intervals denoting the empty set. Index: geometry, intervals; intervals *) (* NOTATION: A "null interval" is any pair of REALs (lo,hi) with lo >= hi. A "point-like" interval is any pair of REALs (lo,hi) with lo = hi. By "empty" we mean an unspecified point-like interval. By we mean the pair (lo,hi) if lo *) PROCEDURE FromAbsBounds (lo, hi: REAL): T RAISES {}; (* Returns the interval |lo,hi| *) PROCEDURE FromBound (lo: REAL; s: REAL): T RAISES {}; (* Returns the interval *) PROCEDURE FromSize (s: REAL): T RAISES {}; (* Returns the interval <0.0,s> *) PROCEDURE Floor(a: T): Interval.T; (* Rounds all points in the interval down to an integer *) PROCEDURE Round(a: T): Interval.T; (* Rounds all points in the interval to the nearest integer *) PROCEDURE Center (READONLY a: T; b: REAL): T RAISES {}; (* Return an interval congruent to a, with middle at b *) (* --- Selection --- *) PROCEDURE Size (READONLY a: T): REAL RAISES {}; (* a.hi - a.lo *) PROCEDURE Middle (READONLY a: T): REAL RAISES {}; (* floor ((a.hi+a.lo)/2.0); an unspecified REAL if empty *) PROCEDURE PickBound (READONLY a: T; n: REAL): Bound RAISES {}; (* Return the bound of a closest to n (one of them if equidistant) *) PROCEDURE Project (READONLY a: T; n: REAL): REAL RAISES {}; (* Return the REAL in a that is closest to n. a must be non empty *) (* --- Transformation --- *) PROCEDURE Move (READONLY a: T; n: REAL): T RAISES {}; (* The interval *) PROCEDURE Inset (READONLY a: T; n: REAL): T RAISES {}; (* If a is empty return empty, else return *) PROCEDURE Change (READONLY a: T; dlo, dhi: REAL): T RAISES {}; (* If a is empty return empty, else return *) PROCEDURE MoveBound (x: Bound; READONLY a: T; dn: REAL): T RAISES {}; (* If r is empty return empty, else add dn to the edge x of a *) PROCEDURE Join (READONLY a, b: T): T RAISES {}; (* the least interval including the union of the points in a and b *) PROCEDURE Meet (READONLY a, b: T): T RAISES {}; (* the largest interval included in the intersection of a and b *) PROCEDURE Chop (READONLY a: T; n: REAL; VAR (* out *) b, c: T) RAISES {}; (* Chop an interval in two; b is to the left of c *) TYPE Partition = ARRAY [0..2] OF T; PROCEDURE Factor (READONLY a, by: T; VAR (*out*) f: Partition; dn: REAL) RAISES {}; (* a is partitioned into 3 pieces f[0]..f[2], where f[1] = Meet (a,by). The order of f is such that if i= a.lo and x < a.hi. *) (* Same as FromBounds(FLOAT(a.lo), FLOAT(a.hi) - epsilon) *) PROCEDURE Hash (READONLY a: T): INTEGER; (* == RETURN a suitable hash value *) END RealInterval.