How to make 2d affine transforms smoothly?

B2ea0a70336979de2830f69911b724d7
0
Nick32 101 Jan 24, 2009 at 10:52

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!

2 Replies

Please log in or register to post a reply.

6673a7d3bfd3d1db5e05c5676cc040b6
0
Goz 101 Jan 25, 2009 at 22:57

@Nick32

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.

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.

B2ea0a70336979de2830f69911b724d7
0
Nick32 101 Jan 28, 2009 at 20:13

Thank you, I solved the problem