tags:

views:

257

answers:

1

WPF stores all its data in double precision. I just want to confirm that all transforms, etc., run in double precision.

I'm working on a WPF canvas, which is very large (40,000,000 x 40,000,000), translating and scaling to zoom into it - placing tiles on to it that contain satellite imagery. To scale and translate I'm using a TransformGroup, containing a ScaleTransform and TranslateTransform.

When zoomed in close, the tiles seem to wobble about as you slightly adjust the scaletransform, as if their location on the canvas is slightly changing, even though all I'm changing is the scaletransform. I'm worried that the transforms aren't being done in double-precision, but are being shipped to the hardware and done in single-precision.

Is there any way to control the precision of render transforms? Or at least confirm that it's using double-precision and not single-precision?

Thanks.

A: 

Hi Mikehamer,

some time ago, I noticed the exact same thing: rendered bitmaps will be severely distorted when using extreme transforms. Some tests I did back then convinced me that WPF does indeed forward transforms to the GPU, which then uses single-precision processing instead of double-precision.

The only workaround I found is to simplify the transforms. For instance, rather than giving an image a size of 100,000 by 100,000 units and a scale factor of 0.0001, give it a size of 1 unit and a scale factor of 10. The same thing goes for translation.

Depending on your design, this may mean that your layout logic will become a good deal more complex, as you will have to do some calculations manually that WPF will otherwise do for you. For an application allowing for a large range of zoom levels (such as from a view of the entire earth down to a single building), there just seems to be no other way.

Daniel Wolf