IDL

ROTATE

ROTATE

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 or 2. The dimensions are transposed if the direction is 4 or greater.

Direction

Direction specifies the operation to be performed as follows:

Rotation Directions

Direction

Transpose?

Rotation Counterclockwise

X1

Y1

0

No

None

X0

Y0

1

No

90°

-Y0

X0

2

No

180°

-X0

-Y0

3

No

270°

Y0

-X0

4

Yes

None

Y0

X0

5

Yes

90°

-X0

Y0

6

Yes

180°

-Y0

-X0

7

Yes

270°

X0

-Y0

In the table above, (X0, Y0) are the original subscripts, and (X1, Y1) are the subscripts of the resulting array. The notation -Y0 indicates a reversal of the Y axis, Y1 = Ny - Y0 - 1. Direction is taken modulo 8, so a rotation of -1 is the same as 7, 9 is the same as 1, etc.

Note: The assertion that Array is rotating counterclockwise may cause some confusion. Remember that when arrays are displayed on the screen (using TV or TVSCL, for example), the image is drawn by default with the origin (0,0) at the bottom left corner of the window. (This default can be changed by changing the value of the !ORDER system variable.) When arrays are printed on the console or command log window (using the PRINT command, for example), the (0,0) element is drawn in the upper left corner of the array. This means that while an image displayed in a graphics window appears to rotate counterclockwise, an array printed in the command log appears to rotate clockwise.

Version History


Original

Introduced

See Also


ROT, TRANSPOSE

Notes


This page has no user notes yet. Be the first one!


This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, it may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
© 2014 Exelis Visual Information Solutions