PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

BlitRotated?

Fire Elemental · 03 Jun 2003, 21:15 UTC
I don't know if I'm correct or not, but this is what I noticed. The BlitRotated function seems to draw the Surface using (x, y) as the center point. Maybe it's just me, but this is sort of inconsistant with the other Blit's that draw from the top left corner. I think it would be better if BlitRotated were to also draw from top left. Saves me from having to use a few offsetting calculations :P
yup, thats what it does, it sure is a pain but BlitRotated rotates around the center (good) so it kinda makes sense
id like to see BlitRotatedAroundPoint. I started to write it but ended up not needing it so I gave up

it would work like this...
Code:

void Rasterizer2d::BlitRotated(Point startPos, Point rotAround, int amount, Surface* image) {
//Point newPos = ? (do some trig using startPos, rotAround, and amount)
BlitRotated(newPos, amount, image);
}

pretty easy, if i needed it real bad id figure out the trig but im hoping one of you brilliant people will figure it out for me before i have to think about
oops! sorry for the Java style formatting...
(i use it in my C++ code so much i forgot it might be weird to the rest of the world)
I'm not sure how the BlitRotated function works in PocketFrog, but in GapiDraw it took me less than 10 minutes to add a "center point of rotation in destination rectangle" to the rotating blit operation. Perhaps the implementation does not require a rewrite of the function?
the center point is used because the image area increases with the angles, so with the center point you can calculate by your own way the best top-left point
I'm pretty sure it's just a matter of modifying the transformation matrix. I seem to recall that was the suggestion for doing a combined rotate and scale, I would assume the same holds true in this case as well. I have to be honest though, I'm not sure I know enough at this point to make such a change (my math ain't so hot to put it bluntly), so if anyone else wants to take a crack at it, I'll be happy to integrate your changes in the next release.
Anonymous wrote:the center point is used because the image area increases with the angles, so with the center point you can calculate by your own way the best top-left point


Exactly.. The "top-left-corner" coordinate only makes sense if you rotate a quadratic image 90 deg at a time. Otherwise you will need to calculate the position of the image anyways. It's a bit awkward at first, but think about it. It actually makes much more sense.

On the other hand. I guess most people use the rotate function to rotate quadratic tiles in 90 degrees increments and so maybee that functionality could use its own function. Possibly more optimized as well since cos 0,90,180,270 is 1,0,-1,0 and sin 0,90,180,270 = 0,1,0,-1 and should not need to be calculated at all.

Modified: Hence I don't think you should alter the transformation matrix nor the input for this function.
No, I wasn't going to anyway :) If someone else wants to, that's fine, but I'd be worried about doing more harm than good in this case.
That´s not the first time I forget to login before posting :?
it was me... the double anon combo