Hi,
First off, I'm a noob (sorry). I tried searching the web for a way to do this but haven't had any luck.
What I want to do is take a square image, say 50x50 pixels, and somehow stretch it onto a rhombus with sides of length 50 pixels, so that it's basically like looking at the 2d image from an angle. Also the angle of viewing needs to be variable.
I was thinking that I could write an algorithm for this, where the color of each pixel is the average of the pixels that it would be overlapping if the image were turned at that angle and didn't lose it's original pixellation. However I don't know how well this would work, and it seems like it would be a complicated algorithm to write.
Is there some function out there that's already been written that can do this? Also is it practical to hope that it will run fast enough to draw, say, one hundred rotating images at 60fps? Because if this isn't practical then it won't be worth the trouble anyway.
Wait. Do you want to shear (I'm guessing this is what you meant, since you can't stretch a rectangle into a rhombus), or rotate?
Either way, both can be accomplished using linear transformations, but how you approach it depends on what you're using for graphical output (OpenGL, SDL, images, etc.).
No I mean distort the image so that it fits onto a rhombus. In GML there is a system of functions for doing this, but I don't know what it's C++ counterpart is.
More specifically, the top left corner of your image will be in the top left corner of the rhombus, the top right corner of the image will be in the top right of the rhombus, etc., and all the pixels in between are blended so that you can still recognize the image (at least if your rhombus is somewhat close to being a square).
Sorry, I'm not following. Mainly, I don't understand how what you said is different from a rotation. Can you post a link to the documentation of the functions you're talking about?
But yes, those are the functions I was referring to. They allow you to take a triangular portion of a picture and stretch it into any other shaped triangle, and by splitting your picture into two triangles you can make a square into a rhombus.
Ah-ha. Yes, you want to shear.
Like I said, there are many ways to do this. With OpenGL, for example, it would look a lot like the GML code. You'd start drawing a polygon and you'd give vertices to the library.
It's also possible to transform a bitmap into another.
It all depends on what you have available and what exact results you expect.