diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f51e456..1febcf78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Custom allocator support using the `Allocator` trait for `HashMap`. This means the `HashMap` can be used with `InternalAllocator` to allocate to IWRAM or the `ExternalAllocator` to explicitly allocate to EWRAM. - Support for using windows on the GBA. Windows are used to selectively enable rendering of certain layers or effects. +## Fixed +- Fixed the fast magnitude function in agb_fixnum. This is also used in fast_normalise. Previously only worked for positive (x, y). + ## [0.11.1] - 2022/08/02 Version 0.11.1 brings documentation for fixed point numbers. We recommend all users upgrade to this version since it also includes fixes to a few functions in fixnum. See changed section for breaking changes. diff --git a/agb-fixnum/src/lib.rs b/agb-fixnum/src/lib.rs index d9a546f2..2e5c4171 100644 --- a/agb-fixnum/src/lib.rs +++ b/agb-fixnum/src/lib.rs @@ -693,8 +693,8 @@ impl Vector2D> { /// ``` #[must_use] pub fn fast_magnitude(self) -> Num { - let max = core::cmp::max(self.x, self.y); - let min = core::cmp::min(self.x, self.y); + let max = core::cmp::max(self.x.abs(), self.y.abs()); + let min = core::cmp::min(self.x.abs(), self.y.abs()); max * num!(0.960433870103) + min * num!(0.397824734759) }