From 516d9f4977f1d76c3e1e27f84811556a6efd24ea Mon Sep 17 00:00:00 2001 From: Medusa Slockbower Date: Mon, 30 Jun 2025 20:01:53 -0400 Subject: [PATCH] - Added constants.h - Finished Exponential Tests - Fixed HTML labeling --- CMakeLists.txt | 1 + include/fennec/lang/bits.h | 1 - include/fennec/lang/conditional_types.h | 1 - include/fennec/lang/constants.h | 1 - include/fennec/lang/intrinsics.h | 1 - include/fennec/lang/limits.h | 4 - include/fennec/lang/numeric_transforms.h | 1 - include/fennec/lang/sequences.h | 2 +- include/fennec/lang/type_sequences.h | 4 +- include/fennec/lang/type_traits.h | 3 +- include/fennec/lang/type_transforms.h | 3 +- include/fennec/lang/types.h | 5 - include/fennec/lang/utility.h | 3 +- include/fennec/math/common.h | 9 +- include/fennec/math/detail/__matrix.h | 2 +- include/fennec/math/exponential.h | 1 - include/fennec/math/ext/constants.h | 580 +++++++++++++++++++++++ include/fennec/math/geometric.h | 3 +- include/fennec/math/math.h | 7 + include/fennec/math/relational.h | 1 - include/fennec/math/trigonometric.h | 3 - include/fennec/math/vector.h | 3 + include/fennec/math/vector_traits.h | 3 +- test/tests/math/test_exponential.h | 15 +- 24 files changed, 613 insertions(+), 44 deletions(-) create mode 100644 include/fennec/math/ext/constants.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 94471d9..c745a72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -106,6 +106,7 @@ add_library(fennec STATIC include/fennec/lang/detail/__int.h include/fennec/lang/detail/__stdlib.h include/fennec/math/detail/__matrix.h + include/fennec/math/ext/constants.h ) # add metaprogramming templates as a dependency and also force documentation to be generated when fennec is compiled diff --git a/include/fennec/lang/bits.h b/include/fennec/lang/bits.h index 8d7d65f..76b1633 100644 --- a/include/fennec/lang/bits.h +++ b/include/fennec/lang/bits.h @@ -41,7 +41,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::bit_cast "ToT bit_cast(const FromT& x)" ///
diff --git a/include/fennec/lang/conditional_types.h b/include/fennec/lang/conditional_types.h index 7e2bbc4..90f7fc0 100644 --- a/include/fennec/lang/conditional_types.h +++ b/include/fennec/lang/conditional_types.h @@ -43,7 +43,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::conditional "typename conditional::type"
/// \ref fennec::conditional_t "conditional_t" diff --git a/include/fennec/lang/constants.h b/include/fennec/lang/constants.h index 353e9ae..91f38d8 100644 --- a/include/fennec/lang/constants.h +++ b/include/fennec/lang/constants.h @@ -43,7 +43,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::integral_constant "integral_constant::type"
///
diff --git a/include/fennec/lang/intrinsics.h b/include/fennec/lang/intrinsics.h index 6b1a84d..3600ced 100644 --- a/include/fennec/lang/intrinsics.h +++ b/include/fennec/lang/intrinsics.h @@ -39,7 +39,6 @@ /// ///
Syntax /// Description -/// ///

/// `FENNEC_HAS_BUILTIN_BIT_CAST`
/// `Y FENNEC_BUILTIN_BIT_CAST(X)` diff --git a/include/fennec/lang/limits.h b/include/fennec/lang/limits.h index dc788dc..81a3fc1 100644 --- a/include/fennec/lang/limits.h +++ b/include/fennec/lang/limits.h @@ -45,9 +45,7 @@ /// ///
Member /// Description -/// ///
Traits -/// ///

/// \ref fennec::numeric_limits::is_specialized "is_specialized" ///
@@ -109,7 +107,6 @@ /// \copybrief fennec::numeric_limits::traps /// ///
Binary -/// ///

/// \ref fennec::numeric_limits::radix "radix" ///
@@ -151,7 +148,6 @@ /// \copybrief fennec::numeric_limits::max_exponent10 /// ///
Limits -/// ///

/// \ref fennec::numeric_limits::min "min()" ///
diff --git a/include/fennec/lang/numeric_transforms.h b/include/fennec/lang/numeric_transforms.h index 77b7b23..df45d83 100644 --- a/include/fennec/lang/numeric_transforms.h +++ b/include/fennec/lang/numeric_transforms.h @@ -40,7 +40,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::make_signed "typename make_signed::type"
/// \ref fennec::make_signed_t "make_signed_t" diff --git a/include/fennec/lang/sequences.h b/include/fennec/lang/sequences.h index 60930fd..ae10032 100644 --- a/include/fennec/lang/sequences.h +++ b/include/fennec/lang/sequences.h @@ -38,7 +38,7 @@ /// /// \code #include \endcode /// -/// +///
///
Syntax /// Description /// diff --git a/include/fennec/lang/type_sequences.h b/include/fennec/lang/type_sequences.h index 824d655..44ad140 100644 --- a/include/fennec/lang/type_sequences.h +++ b/include/fennec/lang/type_sequences.h @@ -38,10 +38,9 @@ /// /// \code #include \endcode /// -/// +///
///
Syntax /// Description -/// ///

/// \ref fennec::first_element "typename first_element::type"
/// \ref fennec::first_element_t "first_element_t" @@ -52,7 +51,6 @@ /// \ref fennec::replace_first_element "typename replace_first_element::type"
///
/// \copydoc fennec::replace_first_element -/// ///
/// diff --git a/include/fennec/lang/type_traits.h b/include/fennec/lang/type_traits.h index fe393b3..351b000 100644 --- a/include/fennec/lang/type_traits.h +++ b/include/fennec/lang/type_traits.h @@ -40,10 +40,9 @@ /// \code #include \endcode /// /// -/// +///
///
Syntax /// Description -/// ///

/// \ref fennec::is_void "is_void::value"
/// \ref fennec::is_void_v "is_void_v" diff --git a/include/fennec/lang/type_transforms.h b/include/fennec/lang/type_transforms.h index a140ddb..c071b46 100644 --- a/include/fennec/lang/type_transforms.h +++ b/include/fennec/lang/type_transforms.h @@ -40,10 +40,9 @@ /// \code #include \endcode /// /// -/// +///
///
Syntax /// Description -/// ///

/// \ref fennec::type_transform "type_transform::type"
///
diff --git a/include/fennec/lang/types.h b/include/fennec/lang/types.h index 78b0dd7..5d3a5f7 100644 --- a/include/fennec/lang/types.h +++ b/include/fennec/lang/types.h @@ -39,9 +39,7 @@ /// ///
Type /// Description -/// ///
Basic Types -/// ///

/// \ref fennec::bool_t "bool_t" ///
@@ -113,7 +111,6 @@ /// \copybrief fennec::double_t /// ///
Sized Arithmetic Types -/// ///

/// \ref fennec::int8_t "int8_t" ///
@@ -168,8 +165,6 @@ /// /// ///
Special Types -/// -/// ///

/// \ref fennec::nullptr_t "nullptr_t" ///
diff --git a/include/fennec/lang/utility.h b/include/fennec/lang/utility.h index 2c3023f..8f45c65 100644 --- a/include/fennec/lang/utility.h +++ b/include/fennec/lang/utility.h @@ -38,10 +38,9 @@ /// /// \code #include \endcode /// -/// +///
///
Syntax /// Description -/// ///

/// \ref fennec::forward "T&& forward(x)"
///
diff --git a/include/fennec/math/common.h b/include/fennec/math/common.h index a4e669a..ca037f0 100644 --- a/include/fennec/math/common.h +++ b/include/fennec/math/common.h @@ -49,7 +49,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::abs(fennec::genType) "genIType abs(genIType x)"
/// \ref fennec::abs(fennec::genType) "genFType abs(genFType x)"
@@ -73,7 +72,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::floor(fennec::genType) "genFType floor(genFType x)"
/// \ref fennec::floor(fennec::genType) "genDType floor(genDType x)" @@ -116,7 +114,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::fract(fennec::genType) "genFType fract(genFType x)"
/// \ref fennec::fract(fennec::genType) "genDType fract(genDType x)" @@ -169,7 +166,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::floatBitsToInt(fennec::genType) "genIType floatBitsToInt(genType value)"
/// \ref fennec::floatBitsToUint(fennec::genType) "genUType floatBitsToUint(genType value)" @@ -235,7 +231,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::step "step(float edge, genFType x)"
/// \ref fennec::step "step(genFType edge, genFType x)"
@@ -324,7 +319,7 @@ constexpr vector abs(const vector& x) /// \param x input value template constexpr genType sign(genType x) - { return (x < 0 ? -1 : 1) * static_cast(x != 0); } + { return (x < genType(0) ? genType(-1) : genType(1)) * static_cast(x != 0); } // reduces to cmove // Vector Specializations ---------------------------------------------------------------------------------------------- @@ -869,7 +864,7 @@ constexpr vector clamp(const vector& x, const vect /// \param x The coordinate of the sample location template requires(is_floating_point_v) constexpr genType step(genType edge, genType x) - { return x < edge ? 0.0 : 1.0; } + { return static_cast(not(x < edge)); } // Vector Specializations ---------------------------------------------------------------------------------------------- diff --git a/include/fennec/math/detail/__matrix.h b/include/fennec/math/detail/__matrix.h index 52b5be6..29066ad 100644 --- a/include/fennec/math/detail/__matrix.h +++ b/include/fennec/math/detail/__matrix.h @@ -114,7 +114,7 @@ constexpr matrix inverse(const matrix i( ( m[1][1] * c5 - m[1][2] * c4 + m[1][3] * c3) * invdet diff --git a/include/fennec/math/exponential.h b/include/fennec/math/exponential.h index dc70083..48f3695 100644 --- a/include/fennec/math/exponential.h +++ b/include/fennec/math/exponential.h @@ -47,7 +47,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::pow(fennec::genType, fennec::genType) "genFType pow(genFType x, genFType y)" ///
diff --git a/include/fennec/math/ext/constants.h b/include/fennec/math/ext/constants.h new file mode 100644 index 0000000..ed6ee12 --- /dev/null +++ b/include/fennec/math/ext/constants.h @@ -0,0 +1,580 @@ +// ===================================================================================================================== +// fennec, a free and open source game engine +// Copyright © 2025 Medusa Slockbower +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// ===================================================================================================================== + +/// +/// \file constants.h +/// \brief \ref fennec_math_ext_constants +/// +/// +/// \details +/// \author Medusa Slockbower +/// +/// \copyright Copyright © 2025 Medusa Slockbower ([GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html)) +/// +/// + +#ifndef FENNEC_MATH_EXT_CONSTANTS_H +#define FENNEC_MATH_EXT_CONSTANTS_H + + +/// +/// +/// +/// \page fennec_math_ext_constants Constants +/// +/// \brief Common constants used in mathematics +/// +/// \code #include \endcode +/// +/// +/// +/// \section section_rational_constants Rational Constants +/// +/// +///
Syntax +/// Description +///

+/// \ref fennec::zero "genType zero()" +///
+/// \copydetails fennec::zero +/// +///

+/// \ref fennec::one "genType one()" +///
+/// \copydetails fennec::one +/// +///

+/// \ref fennec::one_half "genType one_half()" +///
+/// \copydetails fennec::one_half +/// +///

+/// \ref fennec::three_over_two "genType three_over_two()" +///
+/// \copydetails fennec::three_over_two +/// +///
+/// +/// +/// +/// \section section_irrational_constants Irrational Constants +/// +/// +///
Syntax +/// Description +///

+/// \ref fennec::two_thirds "genType two_thirds()" +///
+/// \copydetails fennec::two_thirds +/// +///

+/// \ref fennec::sqrt_two "genType sqrt_two()" +///
+/// \copydetails fennec::sqrt_two +/// +///

+/// \ref fennec::sqrt_three "genType sqrt_three()" +///
+/// \copydetails fennec::sqrt_three +/// +///

+/// \ref fennec::sqrt_five "genType sqrt_five()" +///
+/// \copydetails fennec::sqrt_five +/// +///

+/// \ref fennec::sqrt_seven "genType sqrt_seven()" +///
+/// \copydetails fennec::sqrt_seven +/// +///

+/// \ref fennec::sqrt_ten "genType sqrt_ten()" +///
+/// \copydetails fennec::sqrt_ten +/// +///

+/// \ref fennec::one_over_sqrt_two "genType one_over_sqrt_two()" +///
+/// \copydetails fennec::one_over_sqrt_two +/// +///

+/// \ref fennec::one_over_sqrt_three "genType one_over_sqrt_three()" +///
+/// \copydetails fennec::one_over_sqrt_three +/// +///

+/// \ref fennec::one_over_sqrt_five "genType one_over_sqrt_five()" +///
+/// \copydetails fennec::one_over_sqrt_five +/// +///

+/// \ref fennec::cbrt_two "genType cbrt_two()" +///
+/// \copydetails fennec::cbrt_two +/// +///

+/// \ref fennec::qdrt_two "genType qdrt_two()" +///
+/// \copydetails fennec::qdrt_two +/// +///

+/// \ref fennec::two_raised_sqrt_two "genType two_raised_sqrt_two()" +///
+/// \copydetails fennec::two_raised_sqrt_two +///
+/// +/// +/// +/// \section section_pi_constants π +/// +/// +///
Syntax +/// Description +///
π & τ +///

+/// \ref fennec::pi "genType pi()" +///
+/// \copydetails fennec::pi +/// +///

+/// \ref fennec::tau "genType tau()" +///
+/// \copydetails fennec::tau +/// +///
Multiples of π +///

+/// \ref fennec::two_pi "genType two_pi()" +///
+/// \copydetails fennec::two_pi +/// +///

+/// \ref fennec::three_pi "genType three_pi()" +///
+/// \copydetails fennec::three_pi +/// +///

+/// \ref fennec::four_pi "genType four_pi()" +///
+/// \copydetails fennec::four_pi +/// +///

+/// \ref fennec::half_pi "genType half_pi()" +///
+/// \copydetails fennec::half_pi +/// +///

+/// \ref fennec::third_pi "genType third_pi()" +///
+/// \copydetails fennec::third_pi +/// +///

+/// \ref fennec::quarter_pi "genType quarter_pi()" +///
+/// \copydetails fennec::quarter_pi +/// +///

+/// \ref fennec::fifth_pi "genType fifth_pi()" +///
+/// \copydetails fennec::fifth_pi +/// +///

+/// \ref fennec::sixth_pi "genType sixth_pi()" +///
+/// \copydetails fennec::sixth_pi +/// +///

+/// \ref fennec::two_thirds_pi "genType two_thirds_pi()" +///
+/// \copydetails fennec::two_thirds_pi +/// +///
Reciprocals of π +///

+/// \ref fennec::one_over_pi "genType one_over_pi()" +///
+/// \copydetails fennec::one_over_pi +/// +///

+/// \ref fennec::two_over_pi "genType two_over_pi()" +///
+/// \copydetails fennec::two_over_pi +/// +///
Exponentiations of π +///

+/// \ref fennec::pi_sq "genType pi_sq()" +///
+/// \copydetails fennec::pi_sq +/// +///

+/// \ref fennec::pi_cb "genType pi_cb()" +///
+/// \copydetails fennec::pi_cb +/// +///

+/// \ref fennec::sqrt_pi "genType sqrt_pi()" +///
+/// \copydetails fennec::sqrt_pi +/// +///

+/// \ref fennec::one_over_sqrt_pi "genType one_over_sqrt_pi()" +///
+/// \copydetails fennec::one_over_sqrt_pi +/// +///

+/// \ref fennec::sqrt_two_pi "genType sqrt_two_pi()" +///
+/// \copydetails fennec::sqrt_two_pi +/// +///

+/// \ref fennec::one_over_sqrt_two_pi "genType one_over_sqrt_two_pi()" +///
+/// \copydetails fennec::one_over_sqrt_two_pi +/// +///

+/// \ref fennec::cbrt_pi "genType cbrt_pi()" +///
+/// \copydetails fennec::cbrt_pi +/// +///
+/// +/// +/// +/// \section section_e_constants e +/// +/// +///
Syntax +/// Description +///
Multiples of e +///

+/// \ref fennec::e "genType e()" +///
+/// \copydetails fennec::e +/// +///

+/// \ref fennec::half_e "genType half_e()" +///
+/// \copydetails fennec::half_e +/// +///

+/// \ref fennec::two_e "genType two_e()" +///
+/// \copydetails fennec::two_e +/// +///

+/// \ref fennec::one_over_e "genType one_over_e()" +///
+/// \copydetails fennec::one_over_e +/// +///
Exponentiations +///

+/// \ref fennec::e_sq "genType e_sq()" +///
+/// \copydetails fennec::e_sq +/// +///

+/// \ref fennec::e_cb "genType e_cb()" +///
+/// \copydetails fennec::e_cb +/// +///

+/// \ref fennec::sqrt_e "genType sqrt_e()" +///
+/// \copydetails fennec::sqrt_e +/// +///

+/// \ref fennec::one_over_sqrt_e "genType one_over_sqrt_e()" +///
+/// \copydetails fennec::one_over_sqrt_e +/// +///

+/// \ref fennec::e_raised_e "genType e_raised_e()" +///
+/// \copydetails fennec::e_raised_e +/// +///

+/// \ref fennec::e_raised_neg_e "genType e_raised_neg_e()" +///
+/// \copydetails fennec::e_raised_neg_e +/// +///
Exponentiations by π +///

+/// \ref fennec::e_raised_pi "genType e_raised_pi()" +///
+/// \copydetails fennec::e_raised_pi +/// +///

+/// \ref fennec::e_raised_neg_pi "genType e_raised_neg_pi()" +///
+/// \copydetails fennec::e_raised_neg_pi +/// +///

+/// \ref fennec::e_raised_half_pi "genType e_raised_half_pi()" +///
+/// \copydetails fennec::e_raised_half_pi +/// +///

+/// \ref fennec::e_raised_neg_half_pi "genType e_raised_neg_half_pi()" +///
+/// \copydetails fennec::e_raised_neg_half_pi +/// +///
Exponentiations by γ +///

+/// \ref fennec::e_raised_gamma "genType e_raised_gamma()" +///
+/// \copydetails fennec::e_raised_gamma +/// +///

+/// \ref fennec::e_raised_neg_gamma "genType e_raised_neg_gamma()" +///
+/// \copydetails fennec::e_raised_neg_gamma +/// +///
+/// +/// +/// +/// \section section_catalans_constants Catalan's Constant +/// +/// +///
Syntax +/// Description +///

+/// \ref fennec::G "genType G()" +///
+/// \copydetails fennec::G +/// +///

+/// \ref fennec::one_over_G "genType one_over_G()" +///
+/// \copydetails fennec::one_over_G +/// +///

+/// \ref fennec::G_over_pi "genType G_over_pi()" +///
+/// \copydetails fennec::G_over_pi +/// +///

+/// \ref fennec::pi_over_G "genType pi_over_G()" +///
+/// \copydetails fennec::pi_over_G +///
+/// +/// +/// +/// \section section_gamma_constants γ +/// +/// +///
Syntax +/// Description +///

+/// \ref fennec::y "genType y()" +///
+/// \copydetails fennec::y +/// +///

+/// \ref fennec::one_over_y "genType one_over_y()" +///
+/// \copydetails fennec::one_over_y +///
+/// +/// +/// +/// \section section_log_constants Logarithms +/// +/// +///
Syntax +/// Description +///

+/// \ref fennec::log_two "genType log_two()" +///
+/// \copydetails fennec::log_two +///

+/// \ref fennec::log_three "genType log_three()" +///
+/// \copydetails fennec::log_three +///

+/// \ref fennec::log_five "genType log_five()" +///
+/// \copydetails fennec::log_five +///

+/// \ref fennec::log_seven "genType log_seven()" +///
+/// \copydetails fennec::log_seven +///

+/// \ref fennec::log_ten "genType log_ten()" +///
+/// \copydetails fennec::log_ten +///

+/// \ref fennec::one_over_log_ten "genType one_over_log_ten()" +///
+/// \copydetails fennec::one_over_log_ten +///

+/// \ref fennec::log_two_over_log_three "genType log_two_over_log_three()" +///
+/// \copydetails fennec::log_two_over_log_three +///

+/// \ref fennec::log_log_two "genType log_log_two()" +///
+/// \copydetails fennec::log_log_two +///

+/// \ref fennec::log_pi "genType log_pi()" +///
+/// \copydetails fennec::log_pi +///

+/// \ref fennec::log_sqrt_two "genType log_sqrt_two()" +///
+/// \copydetails fennec::log_sqrt_two +///

+/// \ref fennec::log_gamma "genType log_gamma()" +///
+/// \copydetails fennec::log_gamma +///

+/// \ref fennec::log_phi "genType log_phi()" +///
+/// \copydetails fennec::log_phi +/// +/// +///
+/// + +namespace fennec +{ + // http://numbers.computation.free.fr/Constants/Miscellaneous/digits.html + // 50 digits is sufficient for 128-bit floats + +// Rational Constants ================================================================================================== + +template constexpr genType zero() { return genType(0); } ///< \returns The value of \f$0\f$ +template constexpr genType one() { return genType(1); } ///< \returns The value of \f$1\f$ +template constexpr genType one_half() { return genType(0.5); } ///< \returns The value of \f$\frac{1}{2}\f$ +template constexpr genType three_over_two() { return genType(1.5); } ///< \returns The value of \f$\frac{3}{2}\f$ + + + +// Irrational Constants ================================================================================================ + +template constexpr genType one_third() { return 0.33333333333333333333333333333333333333333333333333; } ///< \returns The value of \f$\frac{1}{3}\f$ with the highest precision for \f$genType\f$ +template constexpr genType two_thirds() { return 0.66666666666666666666666666666666666666666666666666; } ///< \returns The value of \f$\frac{2}{3}\f$ with the highest precision for \f$genType\f$ +template constexpr genType sqrt_two() { return 1.41421356237309504880168872420969807856967187537694; } ///< \returns The value of \f$\sqrt{2}\f$ with the highest precision for \f$genType\f$ +template constexpr genType sqrt_three() { return 1.73205080756887729352744634150587236694280525381038; } ///< \returns The value of \f$\sqrt{3}\f$ with the highest precision for \f$genType\f$ +template constexpr genType sqrt_five() { return 2.23606797749978969640917366873127623544061835961152; } ///< \returns The value of \f$\sqrt{5}\f$ with the highest precision for \f$genType\f$ +template constexpr genType sqrt_seven() { return 2.64575131106459059050161575363926042571025918308245; } ///< \returns The value of \f$\sqrt{7}\f$ with the highest precision for \f$genType\f$ +template constexpr genType sqrt_ten() { return 3.16227766016837933199889354443271853371955513932521; } ///< \returns The value of \f$\sqrt{10}\f$ with the highest precision for \f$genType\f$ +template constexpr genType one_over_sqrt_two() { return 0.70710678118654752440084436210484903928483593768847; } ///< \returns The value of \f$\frac{1}{\sqrt{2}}\f$ with the highest precision for \f$genType\f$ +template constexpr genType one_over_sqrt_three() { return 0.57735026918962576450914878050195745564760175127012; } ///< \returns The value of \f$\frac{1}{\sqrt{3}}\f$ with the highest precision for \f$genType\f$ +template constexpr genType one_over_sqrt_five() { return 0.44721359549995793928183473374625524708812367192230; } ///< \returns The value of \f$\frac{1}{\sqrt{5}}\f$ with the highest precision for \f$genType\f$ +template constexpr genType cbrt_two() { return 1.25992104989487316476721060727822835057025146470150; } ///< \returns The value of \f$\sqrt[3]{2}\f$ with the highest precision for \f$genType\f$ +template constexpr genType qdrt_two() { return 1.18920711500272106671749997056047591529297209246381; } ///< \returns The value of \f$\sqrt[4]{2}\f$ with the highest precision for \f$genType\f$ +template constexpr genType two_raised_sqrt_two() { return 2.66514414269022518865029724987313984827421131371465; } ///< \returns The value of \f${2}^{\sqrt{2}}\f$ with the highest precision for \f$genType\f$ + + + +// Pi ================================================================================================================== + +// Pi & Tau +template constexpr genType pi() { return 3.14159265358979323846264338327950288419716939937510; } ///< \returns The value of \f$\pi\f$ with the highest precision for \f$genType\f$ +template constexpr genType tau() { return 6.28318530717958647692528676655900576839433879875021; } ///< \returns The value of \f$\tau\f$ with the highest precision for \f$genType\f$ + +// Multiples of Pi +template constexpr genType two_pi() { return 6.28318530717958647692528676655900576839433879875021; } ///< \returns The value of \f$2\pi\f$ with the highest precision for \f$genType\f$ +template constexpr genType three_pi() { return 9.42477796076937971538793014983850865259150819812531; } ///< \returns The value of \f$3\pi\f$ with the highest precision for \f$genType\f$ +template constexpr genType four_pi() { return 12.56637061435917295385057353311801153678867759750042; } ///< \returns The value of \f$4\pi\f$ with the highest precision for \f$genType\f$ + +// Fractions of Pi +template constexpr genType half_pi() { return 1.57079632679489661923132169163975144209858469968755; } ///< \returns The value of \f$\frac{\pi}{2}\f$ with the highest precision for \f$genType\f$ +template constexpr genType third_pi() { return 1.04719755119659774615421446109316762806572313312503; } ///< \returns The value of \f$\frac{\pi}{3}\f$ with the highest precision for \f$genType\f$ +template constexpr genType quarter_pi() { return 0.78539816339744830961566084581987572104929234984377; } ///< \returns The value of \f$\frac{\pi}{4}\f$ with the highest precision for \f$genType\f$ +template constexpr genType fifth_pi() { return 0.62831853071795864769252867665590057683943387987502; } ///< \returns The value of \f$\frac{\pi}{5}\f$ with the highest precision for \f$genType\f$ +template constexpr genType sixth_pi() { return 0.52359877559829887307710723054658381403286156656251; } ///< \returns The value of \f$\frac{\pi}{6}\f$ with the highest precision for \f$genType\f$ +template constexpr genType two_thirds_pi() { return 2.09439510239319549230842892218633525613144626625007; } ///< \returns The value of \f$\frac{2\pi}{3}\f$ with the highest precision for \f$genType\f$ + +// Reciprocals of Pi +template constexpr genType one_over_pi() { return 0.31830988618379067153776752674502872406891929148091; } ///< \returns The value of \f$\frac{1}{\pi}\f$ with the highest precision for \f$genType\f$ +template constexpr genType two_over_pi() { return 0.63661977236758134307553505349005744813783858296182; } ///< \returns The value of \f$\frac{2}{\pi}\f$ with the highest precision for \f$genType\f$ + +// Exponentiations Pi +template constexpr genType pi_sq() { return 9.86960440108935861883449099987615113531369940724079; } ///< \returns The value of \f${\pi}^{2}\f$ with the highest precision for \f$genType\f$ +template constexpr genType pi_cb() { return 31.00627668029982017547631506710139520222528856588510; } ///< \returns The value of \f${\pi}^{2}\f$ with the highest precision for \f$genType\f$ +template constexpr genType sqrt_pi() { return 1.77245385090551602729816748334114518279754945612238; } ///< \returns The value of \f$\sqrt{\pi}\f$ with the highest precision for \f$genType\f$ +template constexpr genType one_over_sqrt_pi() { return 0.56418958354775628694807945156077258584405062932899; } ///< \returns The value of \f$\frac{1}{\sqrt{\pi}}\f$ with the highest precision for \f$genType\f$ +template constexpr genType sqrt_two_pi() { return 1.77245385090551602729816748334114518279754945612238; } ///< \returns The value of \f$\sqrt{2\pi}\f$ with the highest precision for \f$genType\f$ +template constexpr genType one_over_sqrt_two_pi() { return 0.39894228040143267793994605993438186847585863116493; } ///< \returns The value of \f$\frac{1}{\sqrt{2\pi}}\f$ with the highest precision for \f$genType\f$ +template constexpr genType cbrt_pi() { return 1.46459188756152326302014252726379039173859685562793; } ///< \returns The value of \f$\sqrt[3]{\pi}\f$ with the highest precision for \f$genType\f$ + + + +// e =================================================================================================================== + +// Multiples and Reciprocal +template constexpr genType e() { return 2.71828182845904523536028747135266249775724709369995; } ///< \returns The value of \f$e\f$ with the highest precision for \f$genType\f$ +template constexpr genType half_e() { return 1.35914091422952261768014373567633124887862354684997; } ///< \returns The value of \f$\frac{e}{2}\f$ with the highest precision for \f$genType\f$ +template constexpr genType two_e() { return 5.43656365691809047072057494270532499551449418739991; } ///< \returns The value of \f$2e\f$ with the highest precision for \f$genType\f$ +template constexpr genType one_over_e() { return 0.36787944117144232159552377016146086744581113103176; } ///< \returns The value of \f$\frac{1}{e}\f$ with the highest precision for \f$genType\f$ + +// Exponentiations of e +template constexpr genType e_sq() { return 7.38905609893065022723042746057500781318031557055184; } ///< \returns The value of \f$e^2\f$ with the highest precision for \f$genType\f$ +template constexpr genType e_cb() { return 20.08553692318766774092852965458171789698790783855415; } ///< \returns The value of \f$e^3\f$ with the highest precision for \f$genType\f$ +template constexpr genType sqrt_e() { return 1.64872127070012814684865078781416357165377610071014; } ///< \returns The value of \f$\sqrt{e}\f$ with the highest precision for \f$genType\f$ +template constexpr genType one_over_sqrt_e() { return 0.60653065971263342360379953499118045344191813548718; } ///< \returns The value of \f$\frac{1}{\sqrt{e}}\f$ with the highest precision for \f$genType\f$ +template constexpr genType e_raised_e() { return 15.15426224147926418976043027262991190552854853685613; } ///< \returns The value of \f$e^e\f$ with the highest precision for \f$genType\f$ +template constexpr genType e_raised_neg_e() { return 0.065988035845312537076790187596846424938577048252796; } ///< \returns The value of \f$e^-e\f$ with the highest precision for \f$genType\f$ + +// Exponentiations of e by Pi +template constexpr genType e_raised_pi() { return 23.14069263277926900572908636794854738026610624260021; } ///< \returns The value of \f${e}^{ \pi}\f$ with the highest precision for \f$genType\f$ +template constexpr genType e_raised_neg_pi() { return 0.04321391826377224977441773717172801127572810981063; } ///< \returns The value of \f${e}^{-\pi}\f$ with the highest precision for \f$genType\f$ +template constexpr genType e_raised_half_pi() { return 4.81047738096535165547303566670383312639017087466453; } ///< \returns The value of \f${e}^{\frac{ \pi}{2}}\f$ with the highest precision for \f$genType\f$ +template constexpr genType e_raised_neg_half_pi() { return 0.20787957635076190854695561983497877003387784163176; } ///< \returns The value of \f${e}^{\frac{-\pi}{2}}\f$ with the highest precision for \f$genType\f$ + +// Exponentiations of e by Gamma +template constexpr genType e_raised_gamma() { return 1.78107241799019798523650410310717954916964521430343; } ///< \returns The value of \f${e}^{ \gamma}\f$ with the highest precision for \f$genType\f$ +template constexpr genType e_raised_neg_gamma() { return 0.56145948356688516982414321479088078676571038692515; } ///< \returns The value of \f${e}^{-\gamma}\f$ with the highest precision for \f$genType\f$ + + + +// Catalan's Constant ================================================================================================== + +template constexpr genType G() { return 0.91596559417721901505460351493238411077414937428167; } ///< \returns The value of \f$G\f$ with the highest precision for \f$genType\f$ +template constexpr genType one_over_G() { return 1.09174406370390610145415947333389232498605012140824; } ///< \returns The value of \f$\frac{1}{G}\f$ with the highest precision for \f$genType\f$ +template constexpr genType G_over_pi() { return 0.29156090403081878013838445646839491886406615398583; } ///< \returns The value of \f$\frac{G}{\pi}\f$ with the highest precision for \f$genType\f$ +template constexpr genType pi_over_G() { return 3.42981513013245864263455323784799901211670795530093; } ///< \returns The value of \f$\frac{\pi}{G}\f$ with the highest precision for \f$genType\f$ + + + +// Gamma =============================================================================================================== + +template constexpr genType y() { return 0.57721566490153286060651209008240243104215933593992; } ///< \returns The value of \f$\gamma\f$ with the highest precision for \f$genType\f$ +template constexpr genType one_over_y() { return 1.73245471460063347358302531586082968115577655226680; } ///< \returns The value of \f$\frac{1}{\gamma}\f$ with the highest precision for \f$genType\f$ + + + +// Logarithms ========================================================================================================== + +template constexpr genType log_two() { return 0.69314718055994530941723212145817656807550013436025; } ///< \returns The value of \f$\log{2}\f$ with the highest precision for \f$genType\f$ +template constexpr genType log_three() { return 1.09861228866810969139524523692252570464749055782274; } ///< \returns The value of \f$\log{3}\f$ with the highest precision for \f$genType\f$ +template constexpr genType log_five() { return 1.60943791243410037460075933322618763952560135426851; } ///< \returns The value of \f$\log{5}\f$ with the highest precision for \f$genType\f$ +template constexpr genType log_seven() { return 1.94591014905531330510535274344317972963708472958186; } ///< \returns The value of \f$\log{7}\f$ with the highest precision for \f$genType\f$ +template constexpr genType log_ten() { return 2.30258509299404568401799145468436420760110148862877; } ///< \returns The value of \f$\log{10}\f$ with the highest precision for \f$genType\f$ +template constexpr genType one_over_log_ten() { return 0.43429448190325182765112891891660508229439700580366; } ///< \returns The value of \f$\frac{1}{\log{10}}\f$ with the highest precision for \f$genType\f$ +template constexpr genType log_two_over_log_three() { return 0.63092975357145743709952711434276085429958564013188; } ///< \returns The value of \f$\frac{\log{2}}{\log{3}}\f$ with the highest precision for \f$genType\f$ +template constexpr genType log_log_two() { return -0.36651292058166432701243915823266946945426344783711; } ///< \returns The value of \f$\log{\log{2}}\f$ with the highest precision for \f$genType\f$ +template constexpr genType log_pi() { return 1.14472988584940017414342735135305871164729481291531; } ///< \returns The value of \f$\log{\pi}\f$ with the highest precision for \f$genType\f$ +template constexpr genType log_sqrt_two() { return 0.91893853320467274178032973640561763986139747363778; } ///< \returns The value of \f$\log{\sqrt{2}}\f$ with the highest precision for \f$genType\f$ +template constexpr genType log_gamma() { return -0.54953931298164482233766176880290778833069898126306; } ///< \returns The value of \f$\log{\gamma}\f$ with the highest precision for \f$genType\f$ +template constexpr genType log_phi() { return 0.48121182505960344749775891342436842313518433438566; } ///< \returns The value of \f$\log{\phi}\f$ with the highest precision for \f$genType\f$ + +} + +#endif // FENNEC_MATH_EXT_CONSTANTS_H diff --git a/include/fennec/math/geometric.h b/include/fennec/math/geometric.h index 832e173..951a187 100644 --- a/include/fennec/math/geometric.h +++ b/include/fennec/math/geometric.h @@ -48,7 +48,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::dot "float dot(genFType x, genFType y)"
/// \ref fennec::dot "double dot(genDType x, genDType x)" @@ -237,7 +236,7 @@ constexpr vector normalize(const vector& x) /// \param Nref the reference template constexpr vector faceforward(const vector& N, const vector& I, const vector& Nref) - { return fennec::dot(Nref, I) < 0 ? N : -N; } + { return fennec::sign(fennec::dot(Nref, I)) * N; } // reflect ------------------------------------------------------------------------------------------------------------- diff --git a/include/fennec/math/math.h b/include/fennec/math/math.h index 00ad64e..0d01bc9 100644 --- a/include/fennec/math/math.h +++ b/include/fennec/math/math.h @@ -66,6 +66,8 @@ /// - \ref fennec_math_geometric /// - \ref fennec_math_relational /// - \ref fennec_math_trigonometric +/// - \subpage fennec_math_extensions "Extensions" +/// - \ref fennec_math_ext_constants /// /// @@ -91,6 +93,11 @@ /// - \subpage fennec_math_trigonometric /// +/// +/// \page fennec_math_extensions Extensions +/// - \subpage fennec_math_ext_constants +/// + /// /// /// diff --git a/include/fennec/math/relational.h b/include/fennec/math/relational.h index b735319..d7061d3 100644 --- a/include/fennec/math/relational.h +++ b/include/fennec/math/relational.h @@ -41,7 +41,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::lessThan "bvec lessThan(vec x, vec y)"
/// \ref fennec::lessThan "bvec lessThan(dvec x, dvec y)"
diff --git a/include/fennec/math/trigonometric.h b/include/fennec/math/trigonometric.h index 0d4a9db..f0dc69b 100644 --- a/include/fennec/math/trigonometric.h +++ b/include/fennec/math/trigonometric.h @@ -47,7 +47,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::degrees "genFType degrees(genFType x)" ///
@@ -67,7 +66,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::sin "genFType sin(genFType x)" ///
@@ -108,7 +106,6 @@ /// ///
Syntax /// Description -/// ///

/// \ref fennec::sinh "genFType sinh(genFType x)" ///
diff --git a/include/fennec/math/vector.h b/include/fennec/math/vector.h index 0d936ec..040ddff 100644 --- a/include/fennec/math/vector.h +++ b/include/fennec/math/vector.h @@ -97,6 +97,9 @@ /// then \f$V.xy = (0, 1)\f$ /// and \f$V.zy = (2, 1)\f$ /// +/// \section section_vectors_more More Info +/// - \subpage fennec_math_vector_traits +/// /// /// diff --git a/include/fennec/math/vector_traits.h b/include/fennec/math/vector_traits.h index d9c6847..6679669 100644 --- a/include/fennec/math/vector_traits.h +++ b/include/fennec/math/vector_traits.h @@ -39,10 +39,9 @@ /// \code #include \endcode /// /// -/// +///
///
Syntax /// Description -/// ///

/// \ref fennec::is_vector "is_vector::value"
/// \ref fennec::is_vector_v "is_vector_v" diff --git a/test/tests/math/test_exponential.h b/test/tests/math/test_exponential.h index bfe9b9d..3d3b5e9 100644 --- a/test/tests/math/test_exponential.h +++ b/test/tests/math/test_exponential.h @@ -19,7 +19,10 @@ #ifndef FENNEC_TEST_MATH_EXPONENTIAL_H #define FENNEC_TEST_MATH_EXPONENTIAL_H +#include "../../test.h" + #include +#include namespace fennec { @@ -33,12 +36,15 @@ inline void fennec_test_math_exponential() fennec_test_run(fennec::pow(1.0f, 2.0f), 1.0f); fennec_test_run(fennec::pow(2.0f, 0.0f), 1.0f); - fennec_test_run(fennec::pow(2.0f, 1.0f), 1.0f); + fennec_test_run(fennec::pow(2.0f, 1.0f), 2.0f); fennec_test_run(fennec::pow(2.0f, 2.0f), 4.0f); fennec_test_spacer(1); - //fennec_test_run(fennec::exp()) + fennec_test_run(fennec::exp(-1.0f), fennec::one_over_e()); + fennec_test_run(fennec::exp( 0.0f), 1.0f); + fennec_test_run(fennec::exp( 1.0f), fennec::e()); + fennec_test_run(fennec::exp( 2.0f), fennec::e_sq()); fennec_test_spacer(1); @@ -49,7 +55,10 @@ inline void fennec_test_math_exponential() fennec_test_spacer(1); - //fennec_test_run(fennec::log()) + fennec_test_run(fennec::log(fennec::one_over_e()), -1.0f); + fennec_test_run(fennec::log(1.0f), 0.0f); + fennec_test_run(fennec::log(fennec::e()), 1.0f); + fennec_test_run(fennec::log(fennec::e_sq()), 2.0f); fennec_test_spacer(1);