G2dBasic.mesa
Copyright Ó 1984, 1992 by Xerox Corporation. All rights reserved.
Bloomenthal, July 1, 1992 7:03 pm PDT
DIRECTORY Real, Vector2;
G2dBasic:
CEDAR
DEFINITIONS
IMPORTS Real
~ BEGIN
Basic Types
Sign: TYPE ~ {positive, negative};
Border: TYPE ~ {inside, outside, edge}; -- relative to closed, planar region
Box:
TYPE ~
RECORD [min, max: Pair];
-- 2d bounding box
Pair: TYPE ~ Vector2.VEC ¬ [0.0, 0.0]; -- RECORD [x, y: REAL]
Triple:
TYPE ~
RECORD [x, y, z:
REAL ¬ 0.0];
NatPair: TYPE ~ RECORD [x, y: NAT ¬ 0];
IntPair: TYPE ~ RECORD [x, y: INT ¬ 0];
IntegerPair:
TYPE ~
RECORD [x, y:
INTEGER ¬ 0];
Card3: TYPE ~ RECORD [x, y, z: CARD ¬ 0];
Integer3: TYPE ~ RECORD [x, y, z: INTEGER ¬ 0];
Nat3: TYPE ~ RECORD [x, y, z: NAT ¬ 0];
Nearness Types
NearSegment:
TYPE ~
RECORD [
point: Pair ¬ [0.0, 0.0], -- point on 2d segment
inside: BOOL ¬ FALSE, -- true iff point inside segment
w0, w1: REAL ¬ 0.0 -- point = w0*p0+w1*p1
];
Sequences
NatSequence: TYPE ~ REF NatSequenceRep;
NatSequenceRep:
TYPE ~
RECORD [
length: CARDINAL ¬ 0,
element:
SEQUENCE maxLength:
CARDINAL
OF
NAT];
IntegerSequence: TYPE ~ REF IntegerSequenceRep;
IntegerSequenceRep:
TYPE ~
RECORD [
length: CARDINAL ¬ 0,
element: SEQUENCE maxLength: CARDINAL OF INTEGER];
IntSequence: TYPE ~ REF IntSequenceRep;
IntSequenceRep:
TYPE ~
RECORD [
length: CARDINAL ¬ 0,
element:
SEQUENCE maxLength:
CARDINAL
OF
INT];
RealSequence: TYPE ~ REF RealSequenceRep;
RealSequenceRep:
TYPE ~
RECORD [
length: CARDINAL ¬ 0,
element: SEQUENCE maxLength: CARDINAL OF REAL
PairSequence: TYPE ~ REF PairSequenceRep;
PairSequenceRep:
TYPE ~
RECORD [
length: CARDINAL ¬ 0,
element: SEQUENCE maxLength: CARDINAL OF Pair
NatPairSequence: TYPE ~ REF NatPairSequenceRep;
NatPairSequenceRep:
TYPE ~
RECORD [
length: CARDINAL ¬ 0,
element: SEQUENCE maxLength: CARDINAL OF NatPair
];
IntegerPairSequence: TYPE ~ REF IntegerPairSequenceRep;
IntegerPairSequenceRep:
TYPE ~
RECORD [
length: CARDINAL ¬ 0,
element: SEQUENCE maxLength: CARDINAL OF IntegerPair
IntPairSequence: TYPE ~ REF IntPairSequenceRep;
IntPairSequenceRep:
TYPE ~
RECORD [
length: CARDINAL ¬ 0,
element: SEQUENCE maxLength: CARDINAL OF IntPair
];
TripleSequence: TYPE ~ REF TripleSequenceRep;
TripleSequenceRep:
TYPE ~
RECORD [
length: CARDINAL ¬ 0,
element: SEQUENCE maxLength: CARDINAL OF Triple
];
Constants
origin: Pair ~ [0.0, 0.0];
xAxis: Triple ~ [1.0, 0.0, 0.0];
yAxis: Triple ~ [0.0, 1.0, 0.0];
zAxis: Triple ~ [0.0, 0.0, 1.0];
maxNNats: CARDINAL ~ (LAST[CARDINAL]-4-SIZE[NatSequenceRep[0]])/SIZE[NAT];
maxNPairs: CARDINAL ~ (LAST[CARDINAL]-4-SIZE[PairSequenceRep[0]])/SIZE[Pair];
maxNTriples: CARDINAL ~(LAST[CARDINAL]-4-SIZE[TripleSequenceRep[0]])/SIZE[Triple];
Basic Operations
RealMod:
PROC [a, b:
REAL]
RETURNS [
REAL] ~
INLINE {
RETURN[a-Real.Floor[a/b]*b]};
a MOD b for a, b real
ArcCos:
PROC [cos:
REAL]
RETURNS [
REAL];
Return the angle in radians.
ArcCosDeg:
PROC [cos:
REAL]
RETURNS [
REAL];
Return the angle in degrees.
Sequence Copying
CopyNatSequence:
PROC [nats: NatSequence]
RETURNS [NatSequence];
Return a copy of the input sequence of nats.
CopyIntegerSequence:
PROC [integers: IntegerSequence]
RETURNS [IntegerSequence];
Return a copy of the input sequence of triples.
CopyIntSequence:
PROC [ints: IntSequence]
RETURNS [IntSequence];
Return a copy of the input sequence of triples.
CopyRealSequence:
PROC [reals: RealSequence]
RETURNS [RealSequence];
Return a copy of the input sequence of reals.
CopyPairSequence:
PROC [pairs: PairSequence]
RETURNS [PairSequence];
Return a copy of the input sequence of pairs.
CopyIntPairSequence:
PROC [intPairs: IntPairSequence]
RETURNS [IntPairSequence];
Return a copy of the input sequence of intPairs.
CopyIntegerPairSequence:
PROC [integerPairs: IntegerPairSequence]
RETURNS [IntegerPairSequence];
Return a copy of the input sequence of integerPairs.
CopyNatPairSequence:
PROC [natPairs: NatPairSequence]
RETURNS [NatPairSequence];
Return a copy of the input sequence of natPairs.
Adding to a Sequence
AddToNatSequence:
PROC [nats: NatSequence, nat:
NAT]
RETURNS [NatSequence];
AddToIntegerSequence:
PROC [integers: IntegerSequence, integer:
INTEGER]
RETURNS [IntegerSequence];
Add integer to the sequence.
AddToIntSequence:
PROC [ints: IntSequence, int:
INT]
RETURNS [IntSequence];
AddToRealSequence:
PROC [reals: RealSequence, real:
REAL]
RETURNS [RealSequence];
Add real to the sequence.
AddToPairSequence:
PROC [pairs: PairSequence, pair: Pair]
RETURNS [PairSequence];
Add pair to the sequence.
AddToNatPairSequence:
PROC [natPairs: NatPairSequence, natPair: NatPair]
RETURNS [NatPairSequence];
Add natPair to the sequence.
AddToIntPairSequence:
PROC [intPairs: IntPairSequence, intPair: IntPair]
RETURNS [IntPairSequence];
Add intPair to the sequence.
AddToIntegerPairSequence:
PROC [integerPairs: IntegerPairSequence, integerPair: IntegerPair]
RETURNS [IntegerPairSequence];
Add integerPair to the sequence.
Lengthening a Sequence
LengthenNatSequence:
PROC [nats: NatSequence, amount:
REAL ¬ 1.3]
RETURNS [NatSequence];
Return a copy of the input sequence whose maxLength is amount*input.maxLength.
LengthenIntegerSequence:
PROC [integers: IntegerSequence, amount:
REAL ¬ 1.3]
RETURNS [IntegerSequence];
Return a copy of the input sequence whose maxLength is amount*input.maxLength.
LengthenIntSequence:
PROC [ints: IntSequence, amount:
REAL ¬ 1.3]
RETURNS [IntSequence];
Return a copy of the input sequence whose maxLength is amount*input.maxLength.
LengthenRealSequence:
PROC [reals: RealSequence, amount:
REAL ¬ 1.3]
RETURNS [RealSequence];
Return a copy of the input sequence of reals.
LengthenPairSequence:
PROC [pairs: PairSequence, amount:
REAL ¬ 1.3]
RETURNS [PairSequence];
Return a copy of the input sequence whose maxLength is amount*input.maxLength.
LengthenNatPairSequence:
PROC [natPairs: NatPairSequence, amount:
REAL ¬ 1.3]
RETURNS [NatPairSequence];
Return a copy of the input sequence whose maxLength is amount*input.maxLength.
LengthenIntPairSequence:
PROC [intPairs: IntPairSequence, amount:
REAL ¬ 1.3]
RETURNS [IntPairSequence];
Return a copy of the input sequence whose maxLength is amount*input.maxLength.
LengthenIntegerPairSequence:
PROC [integerPairs: IntegerPairSequence, amount:
REAL ¬ 1.3]
RETURNS [IntegerPairSequence];
Return a copy of the input sequence whose maxLength is amount*input.maxLength.
END.