DIRECTORY Vector2 USING [VEC]; ImagerTransformation: CEDAR DEFINITIONS ~ BEGIN VEC: TYPE ~ Vector2.VEC; Transformation: TYPE ~ REF TransformationRep; TransformationRep: TYPE ~ RECORD[ a, b, c, d, e, f: REAL, tx, ty: INTEGER _ 0, integerTrans: BOOL _ FALSE, -- (tx=c AND ty=f) form: NAT _ 0 -- identifies special forms of [a, b, d, e] ]; Create: PROC [a, b, c, d, e, f: REAL] RETURNS [Transformation]; Copy: PROC [m: Transformation] RETURNS [Transformation]; Scale: PROC [s: REAL] RETURNS [Transformation]; Scale2: PROC [s: VEC] RETURNS [Transformation]; Rotate: PROC [r: REAL] RETURNS [Transformation]; Translate: PROC [t: VEC] RETURNS [Transformation]; Concat: PROC [m, n: Transformation] RETURNS [Transformation]; Cat: PROC [m1, m2, m3, m4: Transformation _ NIL] RETURNS [Transformation]; PreScale: PROC [m: Transformation, s: REAL] RETURNS [Transformation]; PreScale2: PROC [m: Transformation, s: VEC] RETURNS [Transformation]; PreRotate: PROC [m: Transformation, r: REAL] RETURNS [Transformation]; PreTranslate: PROC [m: Transformation, t: VEC] RETURNS [Transformation]; PostScale: PROC [m: Transformation, s: REAL] RETURNS [Transformation]; PostScale2: PROC [m: Transformation, s: VEC] RETURNS [Transformation]; PostRotate: PROC [m: Transformation, r: REAL] RETURNS [Transformation]; PostTranslate: PROC [m: Transformation, t: VEC] RETURNS [Transformation]; TranslateTo: PROC [m: Transformation, t: VEC] RETURNS [Transformation]; ApplyPreConcat: PROC [m, p: Transformation]; ApplyPreScale: PROC [m: Transformation, s: REAL]; ApplyPreScale2: PROC [m: Transformation, s: VEC]; ApplyPreRotate: PROC [m: Transformation, r: REAL]; ApplyPreTranslate: PROC [m: Transformation, t: VEC]; ApplyPostConcat: PROC [m, p: Transformation]; ApplyPostScale: PROC [m: Transformation, s: REAL]; ApplyPostScale2: PROC [m: Transformation, s: VEC]; ApplyPostRotate: PROC [m: Transformation, r: REAL]; ApplyPostTranslate: PROC [m: Transformation, t: VEC]; ApplyTranslateTo: PROC [m: Transformation, t: VEC]; ApplyCat: PROC [m: Transformation, m1, m2, m3, m4: Transformation _ NIL]; 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]; Rectangle: TYPE ~ RECORD [x, y, w, h: REAL]; TransformRectangle: PROC [m: Transformation, r: Rectangle] RETURNS [Rectangle]; InverseTransformRectangle: PROC [m: Transformation, r: Rectangle] RETURNS [Rectangle]; FactoredTransformation: TYPE ~ RECORD[r1: REAL, s: VEC, r2: REAL, t: VEC]; Factor: PROC [m: Transformation] RETURNS [f: FactoredTransformation]; Invert: PROC [m: Transformation] RETURNS [Transformation]; Equal: PROC [s, t: Transformation] RETURNS [BOOL]; CloseEnough: PROC [s, t: Transformation, range: REAL _ 2000.0] RETURNS [BOOL]; CloseToTranslation: PROC [s, t: Transformation, range: REAL _ 2000.0] RETURNS [BOOL]; SingularValues: PROC [m: Transformation] RETURNS [VEC]; END. JImagerTransformation.mesa Copyright c 1985 by 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, March 26, 1985 3:37:51 pm PST Creating transformations A two-dimensional affine transformation. Represents the 3 by 3 matrix: a d 0 b e 0 c f 1 The values of a, b, c, d, e, f are always correct. Other fields are performance accelerators. Creates a new transformation: a d 0 b e 0 c f 1 Returns a copy of m. Creates a transformation which scales by s: s 0 0 0 s 0 0 0 1 Creates a transformation which scales x by s.x, y by s.y: s.x 0 0 0 s.y 0 0 0 1 Creates a transformation which rotates counterclockwise by r degrees: cos(r) sin(r) 0 -sin(r) cos(r) 0 0 0 1 Creates a transformation which translates by t.x, t.y: 1 0 0 0 1 0 t.x t.y 1 Combining transformations Returns the matrix product mn: m.a*n.a+m.d*n.b m.a*n.d+m.d*n.e 0 m.b*n.a+m.e*n.b m.b*n.d+m.e*n.e 0 m.c*n.a+m.f*n.b+n.c m.c*n.d+m.f*n.e+n.f 1 Concatenates up to four transformations. Equivalent to Concat[Scale[s], m]. Equivalent to Concat[Scale2[s], m]. Equivalent to Concat[Rotate[r], m]. Equivalent to Concat[Translate[t], m]. Equivalent to Concat[m, Scale[s]]. Equivalent to Concat[m, Scale2[s]]. Equivalent to Concat[m, Rotate[r]]. Equivalent to Concat[m, Translate[t]]. Returns m with origin moved to t: m.a m.d 0 m.b m.e 0 t.x t.y 1 Modifying transformations These operations change the value of an existing Transformation. Take care not to apply these to a Transformation that might be shared! Equivalent to m^ _ Concat[p, m]. Note the order of p and m! Equivalent to m^ _ Concat[Scale[s], m]. Equivalent to m^ _ Concat[Scale2[s], m]. Equivalent to m^ _ Concat[Rotate[r], m]. Equivalent to m^ _ Concat[Translate[t], m]. Equivalent to m^ _ Concat[m, p]. Equivalent to m^ _ Concat[m, Scale[s]]. Equivalent to m^ _ Concat[m, Scale2[s]]. Equivalent to m^ _ Concat[m, Rotate[r]]. Equivalent to m^ _ Concat[m, Translate[t]]. Equivalent to m^ _ TranslateTo[m, t]. Equivalent to m^ _ Cat[m1, m2, m3, m4]. Note that m's initial content is ignored. Applying transformations "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]. Rounds both components of v to integers. Equivalent to InverseTransform[m, DRound[Transform[m, v]]]. Equivalent to InverseTransformVec[m, DRound[TransformVec[m, v]]]. Rectangles Returns the smallest rectangle enclosing the transformed vertices of r. Returns the smallest rectangle enclosing the inverse-transformed vertices of r. Other operations Represents Cat[Rotate[r1], Scale2[s], Rotate[r2], Translate[t]]. Returns f such that m=Cat[Rotate[f.r1], Scale2[f.s], Rotate[f.r2], Translate[f.t]]. Returns m's inverse. Returns (s.a=t.a AND s.b=t.b AND s.c=t.c AND s.d=t.d AND s.e=t.e AND s.f=t.f). Returns TRUE if for all points p such that Transform[s, p] is in [0, 0, range, range], Transform[s, p] and Transform[t, p] differ by at most 1/4 in x and y. Returns TRUE if for all points p such that TransformVec[s, p] is in [0, 0, range, range], TransformVec[s, p] and TransformVec[t, p] differ by at most 1/4 in x and y. 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. Κσ˜codešœ™Kšœ Οmœ1™