CImage:Rot90
The Rot90 method rotates the image by 90 degrees along one or more axes. This is a positive rotation for a right-handed coordinate system; for a 2-dimensional displayed with y increasing upward and image value coming out of the screen, the rotation would be counter-clockwise, rotating data along the horizontal x-axis into data along vertical the y-axis.
bSuccess = CImage:Rot90() bSuccess = CImage:Rot90( nAxisFrom, nAxisTo ) bSuccess = CImage:Rot90( nAxisFrom[], nAxisTo[] ) where |
If no arguments are given, axis 1 ("x") is rotated into axis 2 ("y").
nAxisFrom and nAxisTo are the two axis numbers between 1 and the maximum number of axes supported by Mira.
nAxisFrom[] and nAxisTo[] are arrays that specify a series of "from" axes and a series of "to" axes to perform a series of rotations.
bSuccess is the returned success code. On success it is true, otherwise false.
This method rotates data from the specified first axis into the specified second axis. You also can specify multiple rotations. If no axes are specified, this method rotates axis 1 (the "x" axis) into axis 2 (the "y" axis). If the image does not have equal length along the two axes, the result is an image with the original lengths swapped for the 2 axes; however this behavior can be altered by preceding Rot90 by Expand. In Expand, set the expanded length of the shorter rotation axis to equal the length of the longer axis and set the offset to be 1/2 the difference in length of the 2 axes. This is shown in the example below.
Assuming that image I has 3 or more dimensions, the following script rotates axis 3 into axis 1 through an angle of 90 degrees:
|
-- rotate from axis 3 into axis 1 |
The following script rotates the same 3-dimensional twice: first axis 1 into axis 3, then axis 2 into axis 1:
|
-- rotate axis 1 into axis 3, then axis 2 into axis 1 |
The following script rotates a non-square image so that the result is square, with the old image data positioned in the center of the new image. Suppose you want to rotate image I from axis 1 into axis 2 (in other words, columns become rows). Suppose axis 1 has a length of 500 and axis 2 has a length of 900. Axis 1 would be centered in a square image by shifting it (900-500)/2 = 200 pixels. Use the following sequence of commands:
|
-- expand axis 1 to 900 and offset by 200 pixels |
|
-- rotate 90 degrees, from axis 1 into axis 2 |
A script that works for the general case for rotating axis 1 into axis 2 would look like this:
|
-- n1 and n2 are the length of axis 1 and axis 2 |
|
-- get the length of a square image |
|
|
|
|
|
|
|
|
|
|
|
-- expand and offset the smaller axis |
|
-- rotate 90 degrees, from axis 1 into axis 2 |