The ROTATE function returns a rotated and/or transposed copy of Array. ROTATE can only rotate arrays in multiples of 90 degrees. To rotate by amounts other than multiples of 90 degrees, use the ROT function. Note, however, that ROTATE is more efficient.

ROTATE can also be used to reverse the order of elements in vectors. For example, to reverse the order of elements in the vector X, use the expression ROTATE(X,2). If X = [0,1,2,3] then ROTATE(X,2)yields the resulting array, [3,2,1,0].

Note: Transposition, if specified, is performed before rotation.

Examples


Create and display a wedge image by entering:

F = REPLICATE(1, 256) # FINDGEN(256) & TVSCL, F

To display the image rotated 90 degrees counterclockwise, enter:

TVSCL, ROTATE(F, 1)

Syntax


Result = ROTATE(Array, Direction)

Return Value


Returns the rotated and/or transposed array.

Arguments


Array

The array to be rotated. Array can have only one or two dimensions. The result has the same type as Array. The dimensions of the result are the same as those of Array if Direction is equal to 0, 2, 5, or 7. The dimensions are transposed if the direction is 1, 3, 4, or 6.

Direction

Set this argument to an integer giving the rotation direction, including both reflection and rotation (counterclockwise). Note that the reflection is performed first. Possible values are:

Direction Reflection Rotation

Dimensions

Sample

0

None None

Same

1 None 90° Transposed
2 None 180° Same
3 None 270° Transposed
4 Horizontal 270° Transposed
5 Horizontal None Same
6 Horizontal 90° Transposed
7 Vertical None Same

Version History


Original

Introduced

See Also


ROT, TRANSPOSE