From 102b4f6c2dc24c2cfb11507571142ccf8934bd42 Mon Sep 17 00:00:00 2001 From: Corwin Date: Mon, 8 Aug 2022 18:56:30 +0100 Subject: [PATCH 1/2] take absolute values of the x, y coordinate --- agb-fixnum/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) } From a1ea317b43c10257eb9fcc5a70a08cccb687f562 Mon Sep 17 00:00:00 2001 From: Corwin Date: Mon, 8 Aug 2022 18:57:46 +0100 Subject: [PATCH 2/2] update the changelog to note this fix --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) 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.