DIRECTORY Vector2 USING [VEC]; ImagerTransform: CEDAR DEFINITIONS = BEGIN VEC: TYPE ~ Vector2.VEC; -- RECORD[x, y: REAL]; Pair: TYPE ~ VEC; Rectangle: TYPE ~ RECORD [x, y, w, h: REAL]; IntRectangle: TYPE ~ RECORD [x, y, w, h: INTEGER]; Ref: TYPE ~ REF Rep; Rep: TYPE ~ RECORD[a, b, c, d, e, f: REAL]; Transformation: TYPE ~ Ref; TransformationRec: TYPE ~ Rep; 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]; Get: PROC[m: Ref] RETURNS[Rep] ~ INLINE { RETURN[m^] }; Set: PROC[m: Ref, value: Rep] ~ INLINE { m^ _ value }; GetTrans: PROC[m: Ref] RETURNS[VEC] ~ INLINE { RETURN[[m.c, m.f]] }; SetTrans: PROC[m: Ref, value: VEC] ~ INLINE { m.c _ value.x; m.f _ value.y }; Transform: PROC[m: Ref, v: VEC] RETURNS[VEC]; TransformVec: PROC[m: Ref, v: VEC] RETURNS[VEC]; InverseTransform: PROC[m: Ref, v: VEC] RETURNS[VEC]; InverseTransformVec: PROC[m: Ref, v: VEC] RETURNS[VEC]; CloseEnough: PROC [s, t: Transformation, rangeSize: REAL _ 2000.0] RETURNS [BOOLEAN]; CloseToTranslation: PROC [s, t: Transformation, rangeSize: REAL _ 2000.0] RETURNS [BOOLEAN]; TransformRectangle: PROC[m: Ref, rect: Rectangle] RETURNS[Rectangle]; TransformIntRectangle: PROC[m: Ref, rect: Rectangle] RETURNS[IntRectangle]; SingularValues: PROC [m: Ref] RETURNS [Pair]; END. ImagerTransform.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 12, 1984 4:08:43 pm PDT This interface provides the internal view of the procedures, structures, etc. involved in setting, modifying and using transformations in the imager. A two-dimensional affine transformation; represents the following 3 by 3 matrix: a d 0 b e 0 c f 1 Access to transformation fields. These make 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. These modify an existing transformation in place. 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]]. Get m's contents. Set m to a given transformation. Get m's translation part. Set m's translation part. These apply a transform (or its inverse) to a position or displacement "Point" transformation: [m.a*v.x + m.b*v.y + m.c, m.d*v.x + m.e*v.y + m.f]. "Vector" transformation: [m.a*v.x + m.b*v.y, m.d*v.x + m.e*v.y]. Equivalent to Invert[m].Transform[v]. Equivalent to Invert[m].TransformVec[v]. These test 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 m. 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 achieve. ʘšœ™Jšœ Ïmœ.™9Jšœ!™!J™/J™*J™—™•J™—šÏk ˜ Jšœžœžœ˜J˜—Jšœžœž ˜"šœž˜J˜Jšžœžœ žœÏc˜/Jšœžœžœ˜Jšœ žœžœžœ˜,Jšœžœžœžœ˜2J˜Jšœžœžœ˜šœžœžœžœ˜+™PJ™J™J™——J˜Jšœžœ˜Jšœžœ˜J˜—™ J™Jš Ïnœžœ žœžœžœ˜