rotation - How can i rotate a shape in a matrix by 90 degrees in C? -
i have write rotate function tetris game. have bricks in txt file in 10x10 dimensioned matrix , need catch brick location (l-shape) , rotate 90ᵒ in clockwise.
input:
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
and output must this:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
i rotate whole matrix 90 degrees not output. how can rotate l-shape? or how can make output this? thanks.
edit; here's question: in homework going write rotate function of tetris game. have bricks in txt file in 10x10 dimensioned matrix. catch brick location , rotate 90ᵒ in clockwise. simplicity 2 kinds of bricks going rotate algorithm. “l” character , inverse of “l”. input file can take 4 different combinations of 2 bricks. algorithm must rotate brick in clockwise , write result matrix in output file in same location of executable file. input file name “input.txt” , output file name “output.txt”. program can rotate brick in output file produced before, if given input. sample input , output files in attachment.
if looking algorithm. then, think should first @ pivot element. rotation takes place. seems (4,4) element in input pivot. ofcourse, depends on shape. 90 degree clockwise rotation, regenerate shape pivot. , output.
Comments
Post a Comment