DIRECTORY G2dBasic; G2dVector: CEDAR DEFINITIONS ~ BEGIN Box: TYPE ~ G2dBasic.Box; NatPair: TYPE ~ G2dBasic.NatPair; NearSegment: TYPE ~ G2dBasic.NearSegment; Pair: TYPE ~ G2dBasic.Pair; PairSequence: TYPE ~ G2dBasic.PairSequence; Triple: TYPE ~ G2dBasic.Triple; Null: PROC [v: Pair] RETURNS [BOOL]; Negate: PROC [p: Pair] RETURNS [Pair]; Unit: PROC [p: Pair] RETURNS [Pair]; Mul: PROC [p: Pair, s: REAL] RETURNS [Pair]; Div: PROC [p: Pair, s: REAL] RETURNS [Pair]; Add: PROC [p1, p2: Pair] RETURNS [Pair]; Sub: PROC [p1, p2: Pair] RETURNS [Pair]; Equal: PROC [v1, v2: Pair, epsilon: REAL ¬ 0.001] RETURNS [BOOL]; Dot: PROC [p1, p2: Pair] RETURNS [REAL]; Cross: PROC [p1, p2: Pair] RETURNS [REAL]; Midpoint: PROC [v1, v2: Pair] RETURNS [Pair]; Interp: PROC [t: REAL, v1, v2: Pair] RETURNS [Pair]; Combine: PROC [v1: Pair, s1: REAL, v2: Pair, s2: REAL] RETURNS [Pair]; MulVectors: PROC [v1, v2: Pair] RETURNS [Pair]; DivVectors: PROC [v1, v2: Pair] RETURNS [Pair]; UnitizeSequence: PROC [pairs: PairSequence]; AverageSequence: PROC [pairs: PairSequence] RETURNS [Pair]; MinMaxSequence: PROC [pairs: PairSequence] RETURNS [Box]; NegateSequence: PROC [pairs: PairSequence]; ReverseSequence: PROC [src: PairSequence, dst: PairSequence ¬ NIL] RETURNS [PairSequence]; Length: PROC [p: Pair] RETURNS [REAL]; Square: PROC [p: Pair] RETURNS [REAL]; Distance: PROC [p1, p2: Pair] RETURNS [REAL]; SquareDistance: PROC [p1, p2: Pair] RETURNS [REAL]; SameLength: PROC [v1, v2: Pair] RETURNS [Pair]; SetVectorLength: PROC [v: Pair, length: REAL] RETURNS [Pair]; GetNear2dAccelerator: PROC [p0, p1: Pair] RETURNS [Triple]; NearestToSegment: PROC [p0, p1, q: Pair, acc: Triple ¬ [0, 0, 0]] RETURNS [NearSegment]; NearestToSequence: PROC [p: Pair, points: PairSequence] RETURNS [index: NAT]; Line: PROC [p0, p1: Pair] RETURNS [Triple]; DistanceToLine: PROC [p: Pair, line2d: Triple] RETURNS [REAL]; IntersectTwoLines: PROC [line0, line1: Triple] RETURNS [Pair]; TriangleArea: PROC [p0, p1, p2: Pair] RETURNS [REAL]; NatPairLerp: PROC [t: REAL, a, b: NatPair] RETURNS [Pair]; NatPairDistance: PROC [a, b: NatPair] RETURNS [REAL]; AnglesAgree: PROC [a0, a1: REAL] RETURNS [REAL]; AngleFromVector: PROC [v: Pair, degrees: BOOL ¬ FALSE] RETURNS [REAL]; END. H G2dVector.mesa Copyright Σ 1984, 1992 by Xerox Corporation. All rights reserved. Bloomenthal, July 1, 1992 7:06 pm PDT Types Basic Operations on a Single Vector Returns TRUE iff v is the origin. Return the negation of p. Return the unit length vector p. Return the multiplication: p*s. Return the division: p/s. Basic Operations on Two Vectors Return the addition: p1+p2. Return the subtraction: p1-p2. Returns TRUE iff v1 = v2, to within epsilon. Return the inner product: p1.p2. Return the cross product: p1Xp2. Return 0.5*(v1+v2). Return v1+t(v2-v1). Return s1*v1+s2*v2. Return p1*p2, component-wise multiplication. Return p1/p2; component division not performed if v2 component = 0. Basic Operations on Sequence of Vectors Make each pair in the sequence unit length. Return the average of the PairSequence. Return the bounding pairs of the sequence. Negate the sequence of vectors. Reverse the order of src; use dst if # NIL and long enough; if dst = src, in-place reversal. Length and Distance Operations Return the length of p: |p|. Return the square of the length of p. Distance between two pairs. Return the square of the distance between two pairs. Return v2 adjusted to be same magnitude as v1. Return v adjusted to be of magnitude length. Nearness Operations Return the 2d accelerator for computing nearest point on the p0-p1 segment. Return the pair on line segment p0p1 nearest to q. If acc # origin, the calculation of NearSegment is accelerated. Return index such that points[index] is nearest to p. Line and Triangle Operations Return the equation for a 2d line through p0 and p1 of the form ax+by+c = 0; a, b, and c are the components of the returned Triple. Return the distance from the point p to the line. Return the intersection of the two lines. Return the area of the triangle. NatPair Operations Interpolation: return t*a+(1-t)*b. Return the distance between a and b. Miscellaneous Operations a0, a1 in radians. Return 1 if angles fully agree, 0 if they are antipodal. Return angle between vector v and xAxis. (xAxis: 0, yAxis: P/2, -xAxis: P, -yAxis: 3*P/2) Κ6•NewlineDelimiter –"cedarcode" style™™Jšœ Οeœ6™B™%J™—JšΟk œ ˜J˜—JšΠln œžœž ˜Jšœž˜headšΟl™Jšœžœ˜Jšœ žœ˜#Jšœ žœ˜)Jšœžœ˜Jšœžœ˜+Jšœžœ˜!—š #™#šΟnœžœ žœžœ˜$Jšœžœ™!—J™š‘œžœ žœ˜&J™J™—š‘œžœ žœ˜$J™ J™—š‘œžœžœžœ˜,J™J™—š‘œžœžœžœ˜,J™——š ™š‘œžœžœ˜(J™J™—š‘œžœžœ˜(J™J™—š ‘œžœžœ žœžœ˜AJšœžœ ™,J˜—š‘œžœžœžœ˜(Jšœ ™ J™—š‘œžœžœžœ˜*JšœΟoœ™ J™—šΠbnœžœž œ˜-J™J™—š‘œžœžœžœ˜4J™J™—š £œžœžœžœž œ˜FJ™J™—š‘ œžœžœ˜/J™,J™—š‘ œžœžœ˜/J™C——š '™'š‘œžœ˜,J™+J˜—š‘œžœžœ˜;Jšœ'™'J™—š‘œžœžœ˜9J™*J™—š‘œžœ˜+J™J™—š‘œžœ)žœžœ˜ZJšœ'Οsœ2™\——š ™š‘œžœ žœžœ˜&Jšœ™J™—š‘œžœ žœžœ˜&Jšœ%™%J˜—š‘œžœžœžœ˜-J™J˜—š‘œžœžœžœ˜3J™4J™—š‘ œžœžœ˜/J™.J™—š‘œžœžœžœ˜=J™,——š ™š‘œžœžœ ˜;J™KJ™—š‘œžœ+žœ˜XJ™2J™?J™—š‘œžœ!žœ žœ˜MJ™5——š ™š‘œžœžœ ˜+J™LJ™8J™—š‘œžœžœžœ˜>J™1J™—š‘œžœžœ˜>J™)J™—š‘ œžœžœžœ˜5J™ ——š ™š‘ œžœžœžœ˜:J™"J˜—š‘œžœžœžœ˜5J™$——š ™š ‘ œžœ žœžœžœ˜0JšΟcœ;™LJ˜—š ‘œžœžœžœžœžœ˜FJš ’Πos’"œΟgœ §œ §œ™Z——J˜Jšžœ˜—…—ΠN