Matrix rotation 
Author Message
 Matrix rotation

Hi!

Has anyone a function that rotates a square matrix in any direction?

ei:
Before rotation:
1 2
3 4

After rotation:
2 4
1 3

Mickey



Fri, 30 Mar 2001 03:00:00 GMT  
 Matrix rotation
Hi,

There are only two direction, clockwise or anti-clockwise, as far as
rotation in a plan is concerned.

Do you wish rigid body rotation or gazeous nebula rotation?

Need at least a 4 by 4 to see the difference.

Original:           Rigid Body    Gazeous
01 02 03 04    04 08 12 16    02 03 04 08
05 06 07 08    03 07 11 15    01 07 11 12
09 10 11 12    02 06 10 14    05 06 10 16
13 14 15 16    01 05 09 13    09 13 14 15

Note that in the gazeous rotation, the exterior ring has move one element
(look at the final position of 13, 14, 15 and 16 to get the idea) and so had
the inner ring. Doing so, the inner ring had made a full quarter of rotation
while the outer ring had only made a third of a quater of rotation: each
ring has the same tangeantial speed (shifting one element to the
right/bottom/left/top), but the exterior ring having more distance to
travel, it doesn't "rotate" (angular speed) as fast as the inner ring. Such
a movement is not possible inside a rigid body keeping its rigid body form.
Well, enough physic. I assume the rigid body case is what you wish.

For anti-clockwise, original is A(i,j), an n by n matrix, final if B(u,v)
then, get the relation:
B(u,v)= A(1+n-j, i)    ' origin base 1

So, something like:

    For i = 1 To n
        For j = 1 To n
            B(1+n-j, i) = A(i,j)
        Next j
    Next i

I think you may not have problem to solve the clockwise problem (you start
from B to get back to A, since applying clockwise rotation to the obtained B
is supposed to give back A).

Hope it may help,
Vanderghast, Access MVP.

    B(m,n)


Quote:
>Hi!

>Has anyone a function that rotates a square matrix in any direction?

>ei:
>Before rotation:
>1 2
>3 4

>After rotation:
>2 4
>1 3

>Mickey



Fri, 30 Mar 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Rotation-matrix from two vectors

2. obtaining an axis rotation from a matrix

3. X,Y,Z rotation from matrix? Is possible?

4. Text Block rotation in a line.

5. Tracking shape position and rotation WHILE moving

6. Table Rotation

7. Image Rotation

8. getting the region of a usercontrol ? (for rotation)

9. page rotation

10. 3D Rotation Points

11. 3d rotation's

12. 2D Rotation

 

 
Powered by phpBB® Forum Software