[PATCH 4/4] d2d1: Implement cubic bezier-line intersection.

Paul Gofman gofmanp at gmail.com
Wed Apr 1 11:46:06 CDT 2020


On 4/1/20 19:04, Giovanni Mascellani wrote:
> Hi,
>
> Il 31/03/20 22:11, Connor McAdams ha scritto:
>> +    p = (3.0f * b - a * a) / 3.0f;
>> +    p_3 = p / 3.0f;
>> +    q = (2.0f * a * a * a - 9.0f * a * b + 27.0f * c) / 27.0f;
>> +    q2 = q / 2.0f;
>> +    disc = q2 * q2 + p_3 * p_3 * p_3;
> I don't think it is advisable to use Cardano's formula to solve a cubic,
> because it can go numerically bad in a lot of ways. After a quick chat
> with a friend into numerical computing, it seems that it is probably
> better to do a few iterations of a numerical method, like the Aberth
> method (see the Wikipedia page), which should converge rather quickly
> and more or less always if the initial values are chosen not to be
> symmetrical around the real axis. However, it requires to use complex
> numbers.
Given the complex roots are not needed here and the polynomial is always
cubic, is this generic method really beneficial? It would probably be
simpler and quicker to find one root x1 with simple bisection, then
divide the polynomial into (x - x1) and deal with remaining quadratic
equation.




More information about the wine-devel mailing list