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;