Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Happybobjr on October 09, 2011, 04:55:47 pm
-
Ok, so i have a rotation routine.
:For(X,0,95)
:For(Y,0,63)
:cos(A)->D
:sin(A)->E
:If pxl-Test(X,Y)^r
:Pxl-on((X*D-(Y*E)//128,Y8D+(X-16*E)//128)
:END:END:END
And i do that for every pixel on screen.
Anyone know of a fast way to do this?
-
:cos(A)->D
:sin(A)->E
:For(X,0,95)
:For(Y,0,63)
:If pxl-Test(X,Y)^r
:Pxl-on(X-Y*E//128,Y8D+(X-16*E)//128)
:END:END:END
That's a bit more optimized, although I'm sure Runer could improve upon it.
-
lol. I was looking more for an optimization in concept.
Like it would be better to only test pixels above (lesser y value) than vertical shift.
-
If you didn't mind a 90 degree rotation, then this might be more optimized:
:For(A,0,95
:A^12->X
:A/8->Y
:Pt-On(X,Y,RotC(Pt-get(X,Y)))
:END
-
that will only turn 90 degrees though, correct :(
-
Yes.
-
I am good now, thanks for trying to help.
-
Instead of scanning the pixels in the back buffer and projecting them to the front buffer, you will get better results if you scan the front buffer and inverse-project from the back buffer. This assures that every pixel is accounted for which won't happen if you do it the other way.
But as far as speed I don't think you can optimize more than that. As Qwerty said, definitely pre-compute the sine and cosine before your for loops.
-
Ok thanks, but i don't exactly get what inverse-project means.
Didn't realize i put them inside the loop :/. Thank you very much for that. Guess i need sleep.
-
Actually, it's better if you get rid of all the multiplication :P
Something like this (untested):
cos(A)*2→D
sin(A)*2→E
.Upper left corner (scaled by 256) in B,C
0→B
0→C
For(Y,0,63)
B-E→B→I
C+D→C→J
For(X,0,95)
If pxl-Test(I+D→I/256,J+E→J/256)r
pxl-On(X,Y)
End
End