Re: LZ: Rotation...
[Prev][Next][Index][Thread]
Re: LZ: Rotation...
On Mon, 16 Jun 1997 14:44:07 -0500 Buddy Smith <ti85calc@bellsouth.net>
writes:
>
>Thanx abunch. I think that's what I was looking for... however, what
>would new x and newy represent? Thanks to all of you for your help,
>but I still don't quite see how to store data and how to rotate in.
BTW,
>I made the sprite 15x15 so that it has to lines of symmetry, and is not
>two bytes (it wa s 17x17, but that wasted like 16 bytes or
something.....)
>Who wrote rinitsys.85b? That is a great example of rotation. Is that
>person on this list? If so, how'd you do it? rinitsys is great
w/turbo!
>
>Buddy Smith
>ti85calc@bellsouth.net
Okay, I'll try to explain some more. Say you've got a 3x3 sprite like
this:
OXO
OXO
XOX
You want to rotate it 45 deg. I'll start with the upper-left corner.
newx = (-1) * cos(45) - (1) * sin(45) = -1.414 = -1
newy = (1) * cos(45) + (-1) * sin(45) = 0
So you put an 'O' at (-1,0).
You repeat this for all points, and you end up with something like this:
XOO
OXX
OXO
Now with smaller pixels, that won't look as coarse with the roundoff, but
one thing to watch is that your new rotated sprite could be larger than
the original. Using a 15x15 sprite rotated 45 deg., the dimensions would
be 15*sqrt(2) by 15*sqrt(2) or approx. 21x21. That is the largest you
would get, although some of that would remain unused. Another thing is
that pixels might overlap because of rounding, so always rotate from the
original instead of a rotated form of the original (i.e. instead of
rotating it 1 deg. 360 times for a complete rotation, rotate the original
1 deg. to 360 deg. and display). Just remember to make the middle of the
sprite your origin.
Jonathan Anderson
sarlok@juno.com
References: