CImage:Rot270


The Rot270 method rotates the image by 270 degrees along one or more axes. This is equivalent to a -90 degree 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 clockwise, rotating data along the negative x-axis into data along the positive y-axis.

Syntax

bSuccess = CImage:Rot270()

bSuccess = CImage:Rot270( nAxisFrom, nAxisTo )

bSuccess = CImage:Rot270( 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 Rot270 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.

Examples

Assuming that image I has 3 or more dimensions, the following script rotates axis 3 into axis 1 through an angle of 270 degrees:

I:Rot270( 3, 1 )

-- rotate from axis 3 into axis 1

The following script rotates the same 3-dimensional twice: axis 1 into axis 3, then axis 2 into axis 1:

I:Rot270( {1,2}, {3,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:

I:Expand( 1, 900, 200 )

-- expand axis 1 to 900 and offset by 200 pixels

I:Rot270( 1, 2 )

-- rotate 270 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 = I:Len(1); n2 = I:Len(2)

-- n1 and n2 are the length of axis 1 and axis 2

nMax = max( n1, n2 )

-- get the length of a square image

if n1 > n2 then

 

  nAxis = 2; nOff = (n1-n2)/2

 

else

 

  nAxis = 1; nOff = (n2-n1)/2

 

end

 

I:Expand( nAxis, nMax, nOff )

-- expand and offset the smaller axis

I:Rot270( 1, 2 )

-- rotate 270 degrees, from axis 1 into axis 2

Related Topics

Rot180

Rot90

CImage class