[PATCH] d3dx9: Reduce rounding error in D3DXQuaternionToAxisAngle
Alex Henrie
alexhenrie24 at gmail.com
Thu Nov 9 07:41:27 CST 2017
2017-11-09 6:33 GMT-07:00 Henri Verbeet <hverbeet at gmail.com>:
> On 9 November 2017 at 16:45, Alex Henrie <alexhenrie24 at gmail.com> wrote:
>> - *pangle = 2.0f * acosf(pq->w);
>> + *pangle = 2.0f * acos(pq->w); /* acosf has too much rounding error */
> Does that rounding error by any chance get better if you replace
> "acosf(x)" with "atan2f(sqrtf((1.0f - x) * (1.0f + x)), x)"?
That actually makes the rounding error worse on my machine:
printf("acos: %.9f\n", 2*acos(10.0f/22.0f));
printf("acosf: %.9f\n", 2*acosf(10.0f/22.0f));
printf("atan: %.9f\n", 2*atan2f(sqrtf((1.0f - 10.0f/22.0f) * (1.0f +
10.0f/22.0f)), 10.0f/22.0f));
acos: 2.197868979
acosf: 2.197869062
atan: 2.197868824
-Alex
More information about the wine-devel
mailing list