[Wolves] rotate 2d array by 45degrees
Andrew Lewis
andrew at monkeysailor.co.uk
Sat Sep 24 00:19:28 BST 2005
Andrew Lewis wrote:
> Andrew Lewis wrote:
>
>>> I was looking for a generic algorthim but I can't find any that seem
>>> to work the way I want. I guess it;s numeric time
>>>
>>
This should be of some help. for the x,y co-ords of your grid:
where T is 0.5*(total width of the matrix)
X = new x position
Y = new y position
X = ((x-T) * cos(45)) - ((y-T) * sin(45))
Y = ((y-T) * cos(45)) + ((x-T) * sin(45))
I think the size of the new matrix needs to be at least 2T-1 if the
source is odd and square, but it's late and I'm tired so I could be
wrong (again)
This is broadly the right way to do it i think. The problem is that the
array data will be interspersed will null data because of the way the
co-ordinate system works. A leaner way might be to use a list rather
than an array, and pump the data in diagonally from the source table.
This would only work for 45 deg but would be faster and waste less
memory than a general formula like the one above.
spline
More information about the Wolves
mailing list