Image Rotation
TJHJ
Posts: 243
So I have a UOled 128 display and a Uoled Prop 96, I have been plotting a series of points on the screen derived from GPS data, I store the ploted pixels into an array for X and Y. I couldnt find much searching, so here I am.
Here is the big question Can anyone think of a good method to rotate the image on the screen?
How I have been trying to do it was with float math32Full.
Take Point 1, Find L and Theta from pixel 64, 64(Middle of Screen) For L find using the Distance Forumla. ((Ox-X)^2(Oy-y)^2)^(1/2) = L then find theta ArcSin((Y-64)/L)
Now Regenerate the data points for one angle offset - X = L*Sin(Theta+Offset) Y= L*Cos(Theta+offset)
Other than it doesnt work how it should, this is aweful. So if anyone knows of an object that rotates an image, or how to do it easily it would be greatly appricated.
Thank you
TJ
·
Here is the big question Can anyone think of a good method to rotate the image on the screen?
How I have been trying to do it was with float math32Full.
Take Point 1, Find L and Theta from pixel 64, 64(Middle of Screen) For L find using the Distance Forumla. ((Ox-X)^2(Oy-y)^2)^(1/2) = L then find theta ArcSin((Y-64)/L)
Now Regenerate the data points for one angle offset - X = L*Sin(Theta+Offset) Y= L*Cos(Theta+offset)
Other than it doesnt work how it should, this is aweful. So if anyone knows of an object that rotates an image, or how to do it easily it would be greatly appricated.
Thank you
TJ
·
Comments
So lots of time on google I came up with this.
http://homepages.inf.ed.ac.uk/rbf/HIPR2/rotate.htm
Which defines the·rotation as the following
So I ended up with the above but Im not getting anywhere? Did I miss something obvious?
Post Edited (TJHJ) : 6/10/2008 5:05:32 AM GMT
So I have a maxium of 500 byte points, into a variable array.
Defined as so
Mapx[noparse][[/noparse]500]
Mapy[noparse][[/noparse]500]
So I would like to do it with a repeat command, but If I made it a bitmap, I think it would calc out faster when it was close to the maxium of the 500 points, but I am horriable at Bitmaps, I have a hard time keeping up with them. But IM open to learn and try anything.
·
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
http://www.leptonica.com/rotation.html
under "rotation by shear".
This is the fast way to rotate images.
Basically your rotation method is converting to polar coordinates
and then after that conversion you can plot any angle of rotation you want with your method to
"Regenerate your data points".
There is a missing + in your distance formula and another problem is that you are losing your
quadrant information (X and Y offset signs +/-) with the distance formula and the theta formula.
Maybe you need an arccos also. Without the lost information you can only rotate points from
one fourth of the screen.
No need to repeat the sin and cos functions for every point in the loop. Calculate as much as you can outside the loop and use them as constants inside the loop.
http://forums.parallax.com/showthread.php?p=609053
http://forums.parallax.com/showthread.php?p=642142
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Is this a fixed angle or a variable angle?
Rich