Matrix Rotation of elements - Algorithms
|
12-15-2019, 06:16 AM
(This post was last modified: 12-16-2019 12:54 PM by Ángel Martin.)
Post: #4
|
|||
|
|||
RE: Matrix Rotation of elements - Algorithms
here's a start, surely not the best approach but it seems to do the job:
for an (m x n) matrix, the rotated matrix (one single step, clockwise) bij is given as follows:- FOR k = 0 TO int(m/2)-1 ; current layer FOR j = k+1 TO (n-1-k) ; top row rightwards b(1+k),(j+1) = a(1+k),j NEXT j FOR i = (1+k) TO (m-1-k) ; rightmost column downwards b(i+1),(n-k) = a i,(n-k) NEXT i FOR j = (n-k) TO (2+k) STEP -1 ; bottom row leftwards b(m-k),(j-1) = a(m-k),j NEXT j FOR i = (m-k) TO (2+k) STEP -1 ; leftfmost column upwards b(i-1),(1+k) = a i,(1+k) NEXT i NEXT k ; next layer Edited: corrected typos in indexes "To live or die by your own sword one must first learn to wield it aptly." |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Matrix Rotation of elements - Algorithms - Ángel Martin - 12-12-2019, 02:37 PM
RE: Matrix Rotation of elements - Algorithms - Csaba Tizedes - 12-12-2019, 03:31 PM
RE: Matrix Rotation of elements - Algorithms - Ángel Martin - 12-12-2019, 03:59 PM
RE: Matrix Rotation of elements - Algorithms - Ángel Martin - 12-15-2019 06:16 AM
RE: Matrix Rotation of elements - Algorithms - Ángel Martin - 12-17-2019, 10:46 AM
RE: Matrix Rotation of elements - Algorithms - Valentin Albillo - 12-17-2019, 04:18 PM
RE: Matrix Rotation of elements - Algorithms - Ángel Martin - 12-18-2019, 06:29 AM
RE: Matrix Rotation of elements - Algorithms - Csaba Tizedes - 12-17-2019, 02:22 PM
RE: Matrix Rotation of elements - Algorithms - Ángel Martin - 12-17-2019, 03:51 PM
RE: Matrix Rotation of elements - Algorithms - Paul Dale - 12-18-2019, 07:05 AM
|
User(s) browsing this thread: 1 Guest(s)