DIRECTORY Vector2 USING [VEC]; Matrix2: CEDAR DEFINITIONS ~ BEGIN Ref: TYPE ~ REF Rep; Rep: TYPE ~ RECORD[a, b, c, d, e, f: REAL]; VEC: TYPE ~ Vector2.VEC; Contents: PROC[m: Ref] RETURNS[Rep] ~ INLINE { RETURN[m^] }; FromRec: PROC[Rep] RETURNS[Ref]; Create: PROC[a, b, c, d, e, f: REAL] RETURNS[Ref]; Copy: PROC[m: Ref] RETURNS[Ref]; Translate: PROC[x, y: REAL] RETURNS[Ref]; Scale: PROC[s: REAL] RETURNS[Ref]; Scale2: PROC[sx, sy: REAL] RETURNS[Ref]; Rotate: PROC[a: REAL] RETURNS[Ref]; Concat: PROC[m, n: Ref] RETURNS[Ref]; Invert: PROC[m: Ref] RETURNS[Ref]; PreMultiply: PROC[m, pre: Ref]; PreScale: PROC[m: Ref, s: REAL]; PreScale2: PROC[m: Ref, sx, sy: REAL]; PreRotate: PROC[m: Ref, a: REAL]; PreTranslate: PROC[m: Ref, x, y: REAL]; PostMultiply: PROC[m, post: Ref]; PostScale: PROC[m: Ref, s: REAL]; PostScale2: PROC[m: Ref, sx, sy: REAL]; PostRotate: PROC[m: Ref, a: REAL]; PostTranslate: PROC[m: Ref, x, y: REAL]; Transform: PROC[m: Ref, p: VEC] RETURNS[VEC]; TransformVec: PROC[m: Ref, p: VEC] RETURNS[VEC]; InverseTransform: PROC[m: Ref, p: VEC] RETURNS[VEC]; InverseTransformVec: PROC[m: Ref, p: VEC] RETURNS[VEC]; CloseEnough: PROC[s, t: Ref, rangeSize: REAL _ 2000.0] RETURNS[BOOLEAN]; CloseToTranslation: PROC[s, t: Ref, rangeSize: REAL _ 2000.0] RETURNS[BOOLEAN]; Rectangle: TYPE ~ RECORD[x, y, w, h: REAL]; IntRectangle: TYPE ~ RECORD[x, y, w, h: INTEGER]; TransformRectangle: PROC[m: Ref, rect: Rectangle] RETURNS[Rectangle]; TransformIntRectangle: PROC[m: Ref, rect: Rectangle] RETURNS[IntRectangle]; SingularValues: PROC[m: Ref] RETURNS[VEC]; END. äMatrix2.mesa Copyright c 1984, Xerox Corporation. All rights reserved. Frank Crow, July 31, 1983 3:28 pm Michael Plass, February 7, 1984 10:44:55 am PST Doug Wyatt, August 8, 1984 10:40:03 am PDT Homogeneous transformation matrices for two dimensions. Types Represents the following 3 by 3 matrix: a d 0 b e 0 c f 1 Converting between Ref and Rep. Creating new transformation matrices. Create a new transformation. Make a copy of m. Equivalent to Create[1, 0, x, 0, 1, y]. Equivalent to Create[s, 0, 0, 0, s, 0]. Equivalent to Create[sx, 0, 0, 0, sy, 0]. Equivalent to Create[cos(a), -sin(a), 0, sin(a), cos(a), 0]. Angle a is in degrees. Returns the matrix product mn. Returns m's inverse. Altering an existing matrix. Equivalent to m^ _ Concat[pre, m]^. Equivalent to PreMultiply[m, Scale[s]]. Equivalent to PreMultiply[m, Scale2[sx, sy]]. Equivalent to PreMultiply[m, Rotate[a]]. Equivalent to PreMultiply[m, Translate[x, y]]. Equivalent to m^ _ Concat[m, post]^. Equivalent to PostMultiply[m, Scale[s]]. Equivalent to PostMultiply[m, Scale2[sx, sy]]. Equivalent to PostMultiply[m, Rotate[a]]. Equivalent to PostMultiply[m, Translate[x, y]]. Applying a transformation. "Point" transformation: [m.a*p.x + m.b*p.y + m.c, m.d*p.x + m.e*p.y + m.f]. "Vector" transformation: [m.a*p.x + m.b*p.y, m.d*p.x + m.e*p.y]. Equivalent to Invert[m].Transform[p]. Equivalent to Invert[m].TransformVec[p]. Testing for transformations that are close to each other. Returns TRUE if for all points p such that Transform[p, s] is in [0, 0, rangeSize, rangeSize], Transform[p, s] and Transform[p, t] differ by at most 1/4 pixel. Returns TRUE if for all points p such that TransformVec[p, s] is in [0, 0, rangeSize, rangeSize], TransformVec[p, s] and TransformVec[p, t] differ by at most 1/4 pixel. These always return rectangles, thus "hard" transforms will cause a bounding box to be returned Computing singular values Returns the singular values of the non-translation portion of the transform. These are the square roots of the eigenvalues of the symmetric matrix MMT, where M is the non-translation portion. The x component is the larger of the two. These correspond to the maximum and minimum magnitudes that the image of a unit vector can achive. Êu˜šœ ™ Jšœ Ïmœ/™:Jšœ!™!J™/J™*J™—™7J™—šÏk ˜ Jšœžœžœ˜J˜—Jšœ žœž ˜Jšœž˜J˜™J™Jšœžœžœ˜šœžœžœžœ˜+™'J™J™J™——J˜Jšžœžœ žœ˜J˜—™J™Jš Ïnœžœ žœžœžœ˜