CDOrientExtrasImpl.mesa (part of Chipndale)
Copyright © 1984 by Xerox Corporation. All rights reserved.
Ch. Jacobi, Mike Spreitzer, December 13, 1984 11:32:47 am PST
last edited by Ch. Jacobi, December 16, 1984 9:58:53 pm PST
DIRECTORY
CD,
CDOrient,
CDOrientExtras,
Imager;
CDOrientExtrasImpl: CEDAR PROGRAM
IMPORTS Imager
EXPORTS CDOrientExtras =
BEGIN
original: CD.Orientation = CDOrient.original;
rotate90: CD.Orientation = CDOrient.rotate90;
rotate180: CD.Orientation = CDOrient.rotate180;
rotate270: CD.Orientation = CDOrient.rotate270;
CreateTransform: PUBLIC PROC [
cellSize: CD.Position,
cellInstOrient: CD.Orientation,
cellInstPos: CD.Position ← [0,0]]
RETURNS [Imager.Transformation] =
-- Given the size of a cell,
-- the position and orientation of an instance of that cell in "world"
-- co-ordinates, returns the transformation to be applied to
-- cell points to get world points.
BEGIN
RETURN [SELECT cellInstOrient FROM
original => Imager.MakeT[1, 0, cellInstPos.x, 0, 1, cellInstPos.y],
1 =>   Imager.MakeT[-1, 0, cellInstPos.x+cellSize.x, 0, 1, cellInstPos.y], -- reflection in x
rotate90 => Imager.MakeT[0, -1, cellInstPos.x+cellSize.y, 1, 0, cellInstPos.y], -- 90 degrees clockwise
3 =>   Imager.MakeT[0, 1, cellInstPos.x, 1, 0, cellInstPos.y], -- 90 degrees clockwise followed by reflection in x
rotate180 => Imager.MakeT[-1, 0, cellInstPos.x+cellSize.x, 0, -1, cellInstPos.y+cellSize.y], -- 180 degrees clockwise
5 =>   Imager.MakeT[1, 0, cellInstPos.x, 0, -1, cellInstPos.y+cellSize.y], -- 180 degrees clockwise followed by reflection in x
rotate270 => Imager.MakeT[0, 1, cellInstPos.x, -1, 0, cellInstPos.y+cellSize.x], -- 270 degrees clockwise
7 =>   Imager.MakeT[0, -1, cellInstPos.x+cellSize.y, -1, 0, cellInstPos.y+cellSize.x], -- 270 degrees clockwise followed by reflection in x
ENDCASE => ERROR
];
END;
END.