Freedom-of-Form-Foundation / anatomy3d

A CAD tool for humanoid anatomy alterations. See the anatomy3d-blender repository for more recent work.
https://freedomofform.org/1856/3d-anatomy-project-scope-phase-1-focus-on-a-limb-joint/
GNU General Public License v2.0
7 stars 5 forks source link

"flex" floating point type #9

Closed AdamNorberg closed 3 years ago

AdamNorberg commented 3 years ago

Engine logic currently uses float to surface numeric precision issues sooner. This sets up for a lot of refactoring pain later to swap it to double for production.

In the engine, use a "flex" type that implements all mathematical operators as "double", which can be trivially switched to float at compile time by changing the type of the backing field.

AdamNorberg commented 3 years ago

API should use double, since this is an implementation detail.

AdamNorberg commented 3 years ago

Also, consider Decimal: https://docs.microsoft.com/en-us/dotnet/api/system.decimal?view=net-5.0 , which has a narrower range but many more significant figures than double. Decimal does poorly at expressing numbers on vastly different scales but much better at preserving significant figures when operating on numbers at the same scale within its domain.

AdamNorberg commented 3 years ago

With a bit more thought, maybe Real is the right name for this type, since it is "some real-number type of unknown size, which is much more specific and explanatory than "flex". Other suggestions?

Lathreas commented 3 years ago

I am very much in favor of using Real as the name for this type, as it is clear, intuitive, and abstracts away any implementation details.

AdamNorberg commented 3 years ago

Implemented as Real. Please review: https://github.com/Freedom-of-Form-Foundation/anatomy3d/pull/18