Fixed point support - #154
Closed
richardhozak wants to merge 5 commits into
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello,
this PR implements new parry crate (
parry-i32f32) with fixed point numbers, as a reference fixed point number with 32 bits for integer part and 32 bits for decimal part was used (FixedI32F32) from simba crate.There was some missing functionality in simba, that was needed and is implemented in separate PR in simba repository here dimforge/simba#48
This PR is separated into few commits with different meanings:
Add fixed point supportreal!macro for constructing f32, f64 and FixedI32F32 literals, this is used for all literals throughout the crate, this is needed as Rust does not have custom literals that can be used for fixed point numbersUse feature flags properly, so rust can find functions for fixed point numbersUse conversion functions for converting realsasconversions between floats and integer numbers which do not work for FixedI32F32 and lowest common denominator needs to be used that works both for floats and FixedI32F32, so I used conversion functionsasoperator uses narrowing conversion, I replaced it with functions that use checked conversions which panic if source cannot be converted to destination, is this ok? I have not found any problems with this yetThere are still some tests that do not pass, as fixed point is not as accurate as floats, in parry I found undocumented
improved_fixed_point_supportcfg feature which when enabled fixes some of these tests, so I left it on, but these tests still fail:test mass_properties::mass_properties::test::mass_properties_add_partial_zerotest mass_properties::mass_properties::test::mass_properties_add_subCould anyone point me in the right direction so I can fix these tests and what is the preferred solution for f32/f64/FixedI32F32 <-> Integer conversions?