[PATCH 02/12] d2d1: Add cubic bezier bounds functions.

Connor McAdams conmanx360 at gmail.com
Tue Mar 3 15:59:18 CST 2020

I'm kind of stuck on the epsilon value thing.

Running the bounds checking function through all possibilities of a
quadratic with points 0-100 (i.e p0 = 0-100, p1 = 0-100, p3 = 0-100),
I've calculated the maximum and minimum values of the coefficient a in
the derivative, with the maximum value being 0.000076 and the minimum
being -0.000076. So even with the epsilon value in this patch, it
looks like it'd fail certain quadratics upped to cubics.

I guess the question is, would rounding to 0 if it is less than 0.0005
and greater than -0.0005 be appropriate? How would I go about
calculating that value? It doesn't seem to be exactly clear cut.

On Wed, Feb 26, 2020 at 1:32 PM Henri Verbeet <hverbeet at gmail.com> wrote:
> On Tue, 25 Feb 2020 at 22:51, Connor McAdams <conmanx360 at gmail.com> wrote:
> > Is there anything that can be done in the case of t_c_cube to lower
> > the possibility of that happening?
> >
> One of the advantages of using de Casteljau is that it's one of the
> more numerically stable ways to evaluate Bézier curves. So that's the
> easy option. It may also be possible to do something clever by
> rewriting things to eliminate the (1 - t) factors, and using something
> along the lines of Kahan summation to add things together. (I'm
> clearly doing some handwaving here.) That's probably the harder
> option.
> > I didn't even notice that I wasn't using the constant in that function
> > specifically, that value gets used in a later patch. Good catch. I'll
> > fix that. Is it a good idea to have a macro constant for values like
> > that, or is it better to just make them literals?
> >
> Well, ideally you'd avoid this kind of function or constant entirely,
> and either use something based on the tolerance provided through the
> API where applicable, or based on the magnitudes of the values you're
> working with.

More information about the wine-devel mailing list