<> <> <> <<>> <> <<>> DIRECTORY CD, IPOrient; IPOrientImpl: CEDAR PROGRAM EXPORTS IPOrient ~ BEGIN CDIntToOrien: PUBLIC PROCEDURE[num: INT] RETURNS [orien: IPOrient.Orientation] = { <> SELECT num FROM 0 => orien _ original; 1 => orien _ mirrorX; 2 => orien _ rotate270; 3 => orien _ rotate90X; 4 => orien _ rotate180; 5 => orien _ rotate180X; 6 => orien _ rotate270; 7 => orien _ rotate270X; 8 => orien _ rotate90X; ENDCASE}; CDOrienToInt: PUBLIC PROCEDURE[orien: IPOrient.Orientation] RETURNS [num: INT] = { <> SELECT orien FROM original => num _ 0; mirrorX => num _ 1; rotate270 => num _ 2; rotate90X => num _ 3; rotate180 => num _ 4; rotate180X => num _ 5; rotate270 => num _ 6; rotate270X => num _ 7; rotate90X => num _ 8; ENDCASE}; MapPoint: PUBLIC PROC [pointInCell: CD.Position, cellSize: CD.Position, cellInstOrient: IPOrient.Orientation, cellInstPos: CD.Position _ [0,0]] RETURNS [pointInWorld: CD.Position] = BEGIN <<-- Given an point in a prototype cell, >> <<-- the size of the prototype cell, both in "cell" co-ordinates, and>> <<-- the position and orientation index of an instance of that cell in "world">> <<-- co-ordinates, this procedure returns the world>> <<-- co-ordinates of the point.>> <<-- WARNING: a position of a rect can not be mapped with MapPoint>> SELECT cellInstOrient FROM original => RETURN[CD.Position[ x: cellInstPos.x+pointInCell.x, y: cellInstPos.y+pointInCell.y ]]; mirrorX => -- reflection in x RETURN[CD.Position[ x: cellInstPos.x+cellSize.x-pointInCell.x, y: cellInstPos.y+pointInCell.y ]]; rotate90 => { -- 90 degrees clockwise RETURN[CD.Position[ x: cellInstPos.x+cellSize.y-pointInCell.y, y: cellInstPos.y+pointInCell.x]]; }; rotate90X => { -- 90 degrees clockwise followed by reflection in x RETURN[CD.Position[ x: cellInstPos.x+pointInCell.y, y: cellInstPos.y+pointInCell.x]]; }; rotate180 => { -- 180 degrees clockwise RETURN[CD.Position[ x: cellInstPos.x+cellSize.x-pointInCell.x, y: cellInstPos.y+cellSize.y-pointInCell.y]]; }; rotate180X => { -- 180 degrees clockwise followed by reflection in x RETURN[CD.Position[ x: cellInstPos.x+pointInCell.x, y: cellInstPos.y+cellSize.y-pointInCell.y]]; }; rotate270 => { -- 270 degrees clockwise RETURN[CD.Position[ x: cellInstPos.x+pointInCell.y, y: cellInstPos.y+cellSize.x-pointInCell.x]]; }; rotate270X => { -- 270 degrees clockwise followed by reflection in x RETURN[CD.Position[ x: cellInstPos.x+cellSize.y-pointInCell.y, y: cellInstPos.y+cellSize.x-pointInCell.x]]; }; ENDCASE; END; <<>> END.