|
-
Jan 13th, 2004, 02:44 AM
#1
Thread Starter
Member
Problem in bitmap rotation...HELP
hi;
i am trying to rotate a bitmap, using the usual equations,
origin: x0,y0
current pixel: x1,y1
rule:
xRotate = cos(angle) * (x1-x0) - Sin(angle) (Y1-Y0) + X0
yRotate = Sin(angle) * (x1-x0) - Cos(angle)(y1-y0) + y0
the problem is that i get yRotate negative, or the point is out of boundaries of the new bitmap!!
can anyone give me a complete alg. to rotate a bitmap?
-
Jan 13th, 2004, 09:31 AM
#2
transcendental analytic
I hope you understand that you need a larger bitmap if you rotate any odd angles (that aren't right angled for square bitmaps or 180 degrees for rectangles), the rotated bitmap will be of dimensions you get by rotating two not opposing corners around its center and double the distance to it along the x axis resp y axis.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jan 13th, 2004, 09:08 PM
#3
By the way, the size is:
x = cos(rotation_angle)*height + sin(rotation_angle)*width
y = sin(rotation_angle)*height + cos(rotation_angle)*width
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
-
Jan 13th, 2004, 10:26 PM
#4
transcendental analytic
oops.. i didn't notice this earlier, but the first term in y and yrotate should be negated, shouldn't it?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jan 14th, 2004, 01:36 AM
#5
It's just a derived parametric algorithm (just ), meaning you can think of it parametrically. The basic parametric circle equation rotates differently depending on whether you use sin or cos in the x or y part of the equation, and whether you negate it. Negating the y value will only reverse the rotation and make it start at the opposite end vertically. Negating both would double reverse the rotation (keeping it as it was) and make it start at the opposite end diagonally. There really isn't any correct way I've ever seen, so it's really a matter of preference.
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
-
Jan 14th, 2004, 01:25 PM
#6
transcendental analytic
actually, its quite important that the first term is negated, or you will have it oscillate along a diagonal line rather than rotated.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|