DIRECTORY Vector2 USING [VEC]; ImagerTransformation: CEDAR DEFINITIONS ~ BEGIN Transformation: TYPE ~ REF TransformationRep; TransformationRep: TYPE ~ RECORD[a, b, c, d, e, f: REAL]; VEC: TYPE ~ Vector2.VEC; -- RECORD[x, y: REAL]; Create: PROC[a, b, c, d, e, f: REAL] RETURNS[Transformation]; Copy: PROC[m: Transformation] RETURNS[Transformation]; Translate: PROC[t: VEC] RETURNS[Transformation]; Scale: PROC[s: REAL] RETURNS[Transformation]; Scale2: PROC[s: VEC] RETURNS[Transformation]; Rotate: PROC[a: REAL] RETURNS[Transformation]; Concat: PROC[m, n: Transformation] RETURNS[Transformation]; Cat: PROC[m1, m2, m3, m4, m5, m6: Transformation _ NIL] RETURNS[Transformation]; Invert: PROC[m: Transformation] RETURNS[Transformation]; PreMultiply: PROC[m, pre: Transformation]; PreScale: PROC[m: Transformation, s: REAL]; PreScale2: PROC[m: Transformation, s: VEC]; PreRotate: PROC[m: Transformation, a: REAL]; PreTranslate: PROC[m: Transformation, t: VEC]; PostMultiply: PROC[m, post: Transformation]; PostScale: PROC[m: Transformation, s: REAL]; PostScale2: PROC[m: Transformation, s: VEC]; PostRotate: PROC[m: Transformation, a: REAL]; PostTranslate: PROC[m: Transformation, t: VEC]; Get: PROC[m: Transformation] RETURNS[TransformationRep] ~ INLINE { RETURN[m^] }; Set: PROC[m: Transformation, value: TransformationRep] ~ INLINE { m^ _ value }; GetTrans: PROC[m: Transformation] RETURNS[VEC] ~ INLINE { RETURN[[m.c, m.f]] }; SetTrans: PROC[m: Transformation, t: VEC] ~ INLINE { m.c _ t.x; m.f _ t.y }; Transform: PROC[m: Transformation, v: VEC] RETURNS[VEC]; TransformVec: PROC[m: Transformation, v: VEC] RETURNS[VEC]; InverseTransform: PROC[m: Transformation, v: VEC] RETURNS[VEC]; InverseTransformVec: PROC[m: Transformation, v: VEC] RETURNS[VEC]; DRound: PROC[v: VEC] RETURNS[VEC]; RoundXY: PROC[m: Transformation, v: VEC] RETURNS[VEC]; RoundXYVec: PROC[m: Transformation, v: VEC] RETURNS[VEC]; FactoredTransformation: TYPE ~ RECORD[ preRotate: REAL, -- degrees scale: VEC, postRotate: REAL, -- degrees translate: VEC ]; Factor: PROC[Transformation] RETURNS[FactoredTransformation]; Combine: PROC[FactoredTransformation] RETURNS[Transformation]; CloseEnough: PROC[s, t: Transformation, rangeSize: REAL _ 2000.0] RETURNS[BOOL]; CloseToTranslation: PROC[s, t: Transformation, rangeSize: REAL _ 2000.0] RETURNS[BOOL]; Rectangle: TYPE ~ RECORD [x, y, w, h: REAL]; IntRectangle: TYPE ~ RECORD [x, y, w, h: INTEGER]; TransformRectangle: PROC[m: Transformation, rect: Rectangle] RETURNS[Rectangle]; TransformIntRectangle: PROC[m: Transformation, rect: Rectangle] RETURNS[IntRectangle]; SingularValues: PROC[m: Transformation] RETURNS[VEC]; END. RImagerTransformation.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, October 17, 1984 10:28:42 am 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 Creating new transformation matrices. Create a new transformation. Make a copy of m. Equivalent to Create[1, 0, t.x, 0, 1, t.y]. Equivalent to Create[s, 0, 0, 0, s, 0]. Equivalent to Create[s.x, 0, 0, 0, s.y, 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 the concatenation of up to six transformations. Returns m's inverse. Modifying an existing transformation in place. Equivalent to m^ _ Concat[pre, m]^. Equivalent to PreMultiply[m, Scale[s]]. Equivalent to PreMultiply[m, Scale2[s]]. Equivalent to PreMultiply[m, Rotate[a]]. Equivalent to PreMultiply[m, Translate[t]]. Equivalent to m^ _ Concat[m, post]^. Equivalent to PostMultiply[m, Scale[s]]. Equivalent to PostMultiply[m, Scale2[s]]. Equivalent to PostMultiply[m, Rotate[a]]. Equivalent to PostMultiply[m, Translate[t]]. Get m's contents. Set m to a given transformation. Get m's translation part. Set m's translation part. Applying a transformation (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 Transform[Invert[m], v]. Equivalent to TransformVec[Invert[m], v]. Rounding Rounds both components of v to integers. Equivalent to InverseTransform[m, DRound[Transform[m, v]]]. Equivalent to InverseTransformVec[m, DRound[TransformVec[m, v]]]. Factoring a transformation Represents Cat[Rotate[preRotate], Scale2[scale], Rotate[postRotate], Translate[translate]] 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šœžœžœ˜-šœžœžœžœ˜9™PJ™J™J™—J™—Jšžœžœ žœÏc˜/J˜J˜™%J™šÏnœžœžœžœ˜=J™J™—š œžœžœ˜6J™J™—š  œžœžœžœ˜0J™+J˜—š œžœžœžœ˜-J™'J˜—š œžœžœžœ˜-J™+J™—š œžœžœžœ˜.J™SJ™—š œžœžœ˜;J™J™—š œžœ*žœžœ˜PJ™7J™—š œžœžœ˜8J™—J˜—™.J™š  œžœ˜*Jšœ#™#J™—š œžœžœ˜+Jšœ'™'J™—š  œžœžœ˜+Jšœ(™(J™—š  œžœžœ˜,Jšœ(™(J™—š  œžœžœ˜.Jšœ+™+J™—š  œžœ˜,Jšœ$™$J™—š  œžœžœ˜,Jšœ(™(J™—š  œžœžœ˜,Jšœ)™)J™—š  œžœžœ˜-Jšœ)™)J™—š  œžœžœ˜/Jšœ,™,J™—š  œžœžœžœžœ˜PJ™J™—š œžœ0žœ˜OJ™ J™—š  œžœžœžœžœžœ˜OJ™J™—š œžœžœžœ˜LJ™J™——šÏiH™HJ™š   œžœžœžœžœ˜8J™LJ™—š   œžœžœžœžœ˜;J™AJ™—š  œžœžœžœžœ˜?J™&J™—š  œžœžœžœžœ˜BJ™)—J™—š¡™J™š  œžœžœžœžœ˜"J™(J˜—š  œžœžœžœžœ˜6Jšœ;™;J™—š   œžœžœžœžœ˜9JšœA™A—J™—š¡™J™šœžœžœ˜&Jšœ žœŸ ˜Jšœžœ˜ Jšœ žœŸ ˜Jšœ ž˜Jšœ˜J™ZJ™—š œžœžœ˜=J˜—Jš œžœžœ˜>J™J™—š¡<™