Skip to content

Commit f902df1

Browse files
committed
Make minor improvements to vector, matrix, and quaternion classes. Reduce minimum CMake version to 3.27 so GitHub build will work.
1 parent 83676be commit f902df1

File tree

7 files changed

+419
-274
lines changed

7 files changed

+419
-274
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
66
message(FATAL_ERROR "In-source builds prohibited.")
77
endif()
88

9-
cmake_minimum_required(VERSION 3.28)
9+
cmake_minimum_required(VERSION 3.27)
1010
include(FetchContent)
1111
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
1212

CMakePresets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"cmakeMinimumRequired":
44
{
55
"major": 3,
6-
"minor": 28,
6+
"minor": 27,
77
"patch": 0
88
},
99
"configurePresets":

src/engine/math/functions.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <engine/math/constants.hpp>
88
#include <cmath>
99
#include <concepts>
10+
#include <tuple>
1011

1112
// export module math.functions;
1213
// import math.constants;
@@ -15,7 +16,7 @@
1516

1617
namespace math {
1718

18-
/// Mathematical functions
19+
/// Mathematical functions.
1920
namespace functions {
2021

2122
/// @name Basic operations
@@ -526,14 +527,15 @@ template <std::floating_point T>
526527
* Splits a value into its integer and fractional components.
527528
*
528529
* @param x Value to split.
529-
* @param[out] i Integer part of @p x.
530530
*
531-
* @return Fractional part of @p x.
531+
* @return Tuple containing the fractional part of @p x, followed by the integer part of @p x.
532532
*/
533533
template <std::floating_point T>
534-
[[nodiscard]] inline T modf(T x, T i)
534+
[[nodiscard]] inline std::tuple<T, T> modf(T x)
535535
{
536-
return std::modf(x, &i);
536+
std::tuple<T, T> result;
537+
std::get<0>(result) = std::modf(x, &std::get<1>(result));
538+
return result;
537539
}
538540

539541
/// @}

src/engine/math/matrix-functions.hpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -102,29 +102,6 @@ template <class T, std::size_t N, std::size_t M>
102102
template <class T, std::size_t N, std::size_t M>
103103
[[nodiscard]] constexpr matrix<T, N, M> div(T a, const matrix<T, N, M>& b) noexcept;
104104

105-
/**
106-
* Extracts the Ith column from a matrix.
107-
*
108-
* @tparam I Index of a column.
109-
* @tparam T Element type.
110-
* @tparam N Number of columns.
111-
* @tparam M Number of rows.
112-
*
113-
* @param m Matrix from which to extract a column.
114-
*
115-
* @return Reference to the Ith column of @p m.
116-
*/
117-
/// @{
118-
template<std::size_t I, class T, std::size_t N, std::size_t M>
119-
[[nodiscard]] constexpr typename matrix<T, N, M>::column_type& get(matrix<T, N, M>& m) noexcept;
120-
template<std::size_t I, class T, std::size_t N, std::size_t M>
121-
[[nodiscard]] constexpr typename matrix<T, N, M>::column_type&& get(matrix<T, N, M>&& m) noexcept;
122-
template<std::size_t I, class T, std::size_t N, std::size_t M>
123-
[[nodiscard]] constexpr const typename matrix<T, N, M>::column_type& get(const matrix<T, N, M>& m) noexcept;
124-
template<std::size_t I, class T, std::size_t N, std::size_t M>
125-
[[nodiscard]] constexpr const typename matrix<T, N, M>::column_type&& get(const matrix<T, N, M>&& m) noexcept;
126-
/// @}
127-
128105
/**
129106
* Calculates the inverse of a square matrix.
130107
*
@@ -445,34 +422,6 @@ constexpr matrix<T, N, M> div(T a, const matrix<T, N, M>& b) noexcept
445422
return div(a, b, std::make_index_sequence<N>{});
446423
}
447424

448-
template<std::size_t I, class T, std::size_t N, std::size_t M>
449-
inline constexpr typename matrix<T, N, M>::column_type& get(matrix<T, N, M>& m) noexcept
450-
{
451-
static_assert(I < N);
452-
return m.columns[I];
453-
}
454-
455-
template<std::size_t I, class T, std::size_t N, std::size_t M>
456-
inline constexpr typename matrix<T, N, M>::column_type&& get(matrix<T, N, M>&& m) noexcept
457-
{
458-
static_assert(I < N);
459-
return std::move(m.columns[I]);
460-
}
461-
462-
template<std::size_t I, class T, std::size_t N, std::size_t M>
463-
inline constexpr const typename matrix<T, N, M>::column_type& get(const matrix<T, N, M>& m) noexcept
464-
{
465-
static_assert(I < N);
466-
return m.columns[I];
467-
}
468-
469-
template<std::size_t I, class T, std::size_t N, std::size_t M>
470-
inline constexpr const typename matrix<T, N, M>::column_type&& get(const matrix<T, N, M>&& m) noexcept
471-
{
472-
static_assert(I < N);
473-
return std::move(m.columns[I]);
474-
}
475-
476425
/// @private
477426
template <class T>
478427
constexpr matrix<T, 2, 2> inverse(const matrix<T, 2, 2>& m) noexcept

0 commit comments

Comments
 (0)