Skip to main content

Microsoft Silverlight

Answered Question Conversion of geometry to single precision happens before transformation is applied.RSS Feed

(0)

shacktoms
shacktoms

Member

Member

185 points

149 Posts

Conversion of geometry to single precision happens before transformation is applied.

At a breakpoint in the debugger, I had the following interaction...

PathFigure dbg_f = new PathFigure();
{System.Windows.Media.PathFigure}
    base {System.Windows.DependencyObject}: {System.Windows.Media.PathFigure}
    IsClosed: false
    IsFilled: false
    Segments: null
    StartPoint: {0,0}
dbg_f.StartPoint = new Point(100000001.0, 0.0);
{100000001,0}
    X: 100000001.0
    Y: 0.0
dbg_f.StartPoint
{100000000,0}
    X: 100000000.0
    Y: 0.0

Note that the X coordinate has lost its precision.  This seems to show that the StartPoint coordinates are being converted to single-precision floating-point even before any tranformation is done on them.  They are get and set as double precision, but internally they are single precision.

The current behavior makes it difficult to make a continuous, rapidly scrolling plot where, say, the X coordinate represents time and the graph scrolls according to a translation matrix, because sooner or later the X-coordinate, as adjusted by the translation, will become a small difference of large numbers.  With the 23 bits of precision in a single-precision float, you lose milliseconds' precision after only a few hours, and the display gets progressively worse after that.  In fact, it degrades faster than that because there are multiplications by single-precision numbers involved in the transformation.

At the very least, you could split the affine transformation and find a translation that could be done before the linear transformation in double precision, and then just do the remaining linear work in single precision.   That might even end up being faster, I don't know.

I think I can work around the limitation, but since these fields are declared as double, rather than float, I am wondering if it is something that is intended to be changed by the time Silverlight 2.0 is released.

mle_ii
mle_ii

Member

Member

242 points

45 Posts

Answered Question

Re: Conversion of geometry to single precision happens before transformation is applied.

Thank you for the information.  This bug is being tracked.

Thanks,
Mike Estes
Microsoft Silverlight

Mike Estes
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities