microsoft / win32metadata

Tooling to generate metadata for Win32 APIs in the Windows SDK.
Other
1.32k stars 112 forks source link

Consider removing `X3DAUDIO_PI` defined as an approximation of PI #896

Closed kennykerr closed 2 years ago

kennykerr commented 2 years ago

Languages/libraries define mathematical constants like this so there's no need for the win32 metadata to include it. Suggest removing it.

e.g.

https://en.cppreference.com/w/cpp/header/numbers

https://doc.rust-lang.org/std/index.html?search=pi

https://docs.microsoft.com/en-us/dotnet/api/system.math.pi?msclkid=36b18f44c1b011ecbc1f0490babe3192&view=net-6.0

riverar commented 2 years ago

Some APIs and structures like X3DAUDIO_EMITTER have constraints built upon this approximation and precision. That structure, for example, has a inner radius angle member that must not exceed X3DAUDIO_PI/4.0.

                            3.141592654f/4.0 = 0.7853981635     // X3DAudio approximation
3.14159265358979323846264338327950288f64/4.0 = 0.78539816339    // Rust native calculation
                                                          ^

An X3D developer swapping this out might introduce subtle errors in edge cases. (Silent and I have run into a somewhat related issue before.)

kennykerr commented 2 years ago

Fair enough. Feel free to close.

riverar commented 2 years ago

Will close for now but if the X3DAudio folks (or anyone else) feels strongly otherwise, re-open. Happy to delete things!