Remember the thread "how to rotate a matrix by 45 degrees"? Here's Oleg's solution (from http://www.jsoftware.com/pipermail/general/2006-April/026991.html ):

           M         =:  (,~ $ 0:)@(+:&.<:)@#           NB. zero result matrix
           N         =:  ,@(,~&.> |."1)@(+/~)@[EMAIL PROTECTED]      NB. source 
indices
           rot       =:  (,`N`M)@]}~


Combining this with Jose's  involute2  :


involute2 =: ([ $ /:@(+/\@(,@(] {. |:@((1 0 + [EMAIL PROTECTED]@|.)@[)) # +:@] $ (, -)@(1 , {:@[)))) {.

We get:

           tetspi =: rot@:(*/ - involute2)

           tetspi  5 5
         0  0  0  0 21  0  0  0  0
         0  0  0 22  0 20  0  0  0
         0  0 23  0  7  0 19  0  0
         0 24  0  8  0  6  0 18  0
        25  0  9  0  1  0  5  0 17
         0 10  0  2  0  4  0 16  0
         0  0 11  0  3  0 15  0  0
         0  0  0 12  0 14  0  0  0
         0  0  0  0 13  0  0  0  0

           load 'viewmat'
           viewmat rot@:(*/ - involute2)  500 500


Your job is to generate this is a cooler/faster/better way.

-Dan

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to