From ce4e1807ded5a6f66ba7c01155c9ea27aae0b9ac Mon Sep 17 00:00:00 2001 From: Brett Date: Sat, 5 Oct 2024 01:13:24 -0400 Subject: [PATCH] make vectors actually have bipolar function --- CMakeLists.txt | 2 +- include/blt/math/matrix.h | 5 +---- include/blt/math/vectors.h | 8 ++++++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b52928c..56ee3d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.20) include(cmake/color.cmake) -set(BLT_VERSION 2.1.0) +set(BLT_VERSION 2.1.1) set(BLT_TARGET BLT) diff --git a/include/blt/math/matrix.h b/include/blt/math/matrix.h index 673a442..8936d3b 100644 --- a/include/blt/math/matrix.h +++ b/include/blt/math/matrix.h @@ -168,10 +168,7 @@ namespace blt { matrix_t copy = *this; for (auto& v : copy.data) - { - for (auto& d : blt::iterate(v.begin(), v.end())) - d = d >= 0 ? 1 : -1; - } + v = v.bipolar(); return copy; } diff --git a/include/blt/math/vectors.h b/include/blt/math/vectors.h index f4fbe9a..d1ec57e 100644 --- a/include/blt/math/vectors.h +++ b/include/blt/math/vectors.h @@ -134,6 +134,14 @@ namespace blt return copy; } + [[nodiscard]] constexpr inline vec bipolar() const + { + auto copy = *this; + for (auto& v : copy.elements) + v = v >= 0 ? 1 : -1; + return copy; + } + [[nodiscard]] constexpr inline T magnitude() const { T total = 0;