File: SVCoordSys2d.mesa
Last edited by Bier on January 28, 1987 12:35:17 pm PST
Copyright © 1984 by Xerox Corporation. All rights reserved.
Contents: Routines for manipulating coordinate systems with respect to each other in 2 dimensions
DIRECTORY
SV2d,
SVModelTypes;
SVCoordSys2d: CEDAR DEFINITIONS =
BEGIN
CoordSystem2d: TYPE = REF CoordSystem2dObj;
CoordSystem2dObj: TYPE = SVModelTypes.CoordSystem2dObj;
Matrix3by3: TYPE = SV2d.Matrix3by3;
Point2d: TYPE = SV2d.Point2d;
Vector2d: TYPE = SV2d.Vector2d;
CreateCoordSys: PROC [mat: Matrix3by3, withRespectTo: CoordSystem2d] RETURNS [newCS: CoordSystem2d];
TellCoordSysAboutPad: PROC [cs: CoordSystem2d];
PadToScreen: PROC [padPoint: Point2d, screen: CoordSystem2d] RETURNS [screenPoint: Point2d];
ScreenToPad: PROC [screenPoint: Point2d, screen: CoordSystem2d] RETURNS [padPoint: Point2d];
FindInTermsOfPad: PROC [cs: CoordSystem2d] RETURNS [mat: Matrix3by3];
FindAinTermsOfB: PROC [a: CoordSystem2d, b: CoordSystem2d] RETURNS [aInTermsOfb: Matrix3by3];
FindTranslationOfAinTermsOfB: PROC [a: CoordSystem2d, b: CoordSystem2d] RETURNS [displacements: Vector2d];
PutAinTermsOfB: PROC [a: CoordSystem2d, b: CoordSystem2d] RETURNS [aInTermsOfb: Matrix3by3];
Finds the matrix and redefines CoordSystem a to be in terms of b from now on.
PlaceAwrtB: PROC [a: CoordSystem2d, b: CoordSystem2d ← NIL, aWRTb: Matrix3by3];
Places a in PAD so that the transform from b to a is aWRTb. Updates a with respect to its immediate reference (a.withRespectTo) accordingly.
PlaceTranslationAwrtB: PROC [a: CoordSystem2d, b: CoordSystem2d ← NIL, origin: Point2d];
Places a in PAD so that the rotation from a to b remains as it is, but the translation is set to origin. Updates a with respect to its immediate reference (a.withRespectTo) accordingly.
TranslateAwrtB: PROC [a: CoordSystem2d, b: CoordSystem2d ← NIL, tx, ty: REAL];
RotateCCWAwrtB: PROC [a: CoordSystem2d, b: CoordSystem2d ← NIL, degrees: REAL];
AlignAwrtB: PROC [a: CoordSystem2d, b: CoordSystem2d ← NIL];
Rotate A as little as possible to align its two axes parallel to two of the axes of B (though not necessarily the same two).
AbutAwrtB: PROC [a: CoordSystem2d, b: CoordSystem2d ← NIL];
Equivalent to PlaceTranslationAwrtB where origin = [0, 0]
These perform the named transform but do not change the coordinate system with respect to which CoordSystem a is defined.
When b is NIL, assumes b = PAD.
For local transforms, let b = a.
END.