# How to make 2d affine transforms smoothly?

2 replies to this topic

### #1Nick32

New Member

• Members
• 4 posts

Posted 24 January 2009 - 10:52 AM

Hi! I'm new in graphics development and this my first post on DevMaster.

In my application (only GDI) I move and rotate some geometric figures. But there are problems:

1) When I rotate figure around axis, in horizontal, vertical and some other positions it looks thicker then in position with angle. It is noticeably on long figures. I implemented anti-aliasing algorithm (based on calculation of pixel coverage), but it did solve the problem.

2)The second problem is when I move object it moves by steps. Even when I use anti-aliasing and floating point representation of coordinates(my be there is bug in rounding? u use floor function).

Thanks!

### #2Goz

Senior Member

• Members
• 575 posts

Posted 25 January 2009 - 10:57 PM

Nick32 said:

Hi! I'm new in graphics development and this my first post on DevMaster.

In my application (only GDI) I move and rotate some geometric figures. But there are problems:

1) When I rotate figure around axis, in horizontal, vertical and some other positions it looks thicker then in position with angle. It is noticeably on long figures. I implemented anti-aliasing algorithm (based on calculation of pixel coverage), but it did solve the problem.

If you draw a square (say 32x32 pixels) does it actually look square? If it doesn't then your aspect ratio is wrong and the rotation will cause the problems you describe above.

Quote

2)The second problem is when I move object it moves by steps. Even when I use anti-aliasing and floating point representation of coordinates(my be there is bug in rounding? u use floor function).

You need to interpolate between the 2 matrices.

Simplest rotational interpolation involves fiddling with the euler angles you feed into your sines and cosines.

A simple 2D rotation will look something like


-sin( theta )  cos( theta )

cos( theta )  sin( theta )



so if you want it to move more smoothly then you, simply, vary your theta values by a smaller amount.

### #3Nick32

New Member

• Members
• 4 posts

Posted 28 January 2009 - 08:13 PM

Thank you, I solved the problem

#### 1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users