mirror of
https://github.com/BlackMATov/vmath.hpp.git
synced 2025-12-13 20:17:58 +07:00
style fixes
This commit is contained in:
@@ -58,7 +58,7 @@ Most functions and types are based on the HLSL ([High-Level Shading Language for
|
||||
- [Matrix Types](#Matrix-Types)
|
||||
- [Vector Operators](#Vector-Operators)
|
||||
- [Matrix Operators](#Matrix-Operators)
|
||||
- [Angle and Trigonometry Functions](#Angle-and-Trigonometry-Functions)
|
||||
- [Angle and Trigonometric Functions](#Angle-and-Trigonometric-Functions)
|
||||
- [Exponential Functions](#Exponential-Functions)
|
||||
- [Common Functions](#Common-Functions)
|
||||
- [Geometric Functions](#Geometric-Functions)
|
||||
@@ -743,7 +743,7 @@ template < typename T, size_t Size >
|
||||
constexpr bool operator<(const mat<T, Size>& xs, const mat<T, Size>& ys);
|
||||
```
|
||||
|
||||
### Angle and Trigonometry Functions
|
||||
### Angle and Trigonometric Functions
|
||||
|
||||
#### Scalar
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace vmath_hpp
|
||||
}
|
||||
|
||||
//
|
||||
// Angle and Trigonometry Functions
|
||||
// Angle and Trigonometric Functions
|
||||
//
|
||||
|
||||
namespace vmath_hpp
|
||||
@@ -228,94 +228,63 @@ namespace vmath_hpp
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
sin(T x) noexcept {
|
||||
return std::sin(x);
|
||||
}
|
||||
sin(T x) noexcept { return std::sin(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
cos(T x) noexcept {
|
||||
return std::cos(x);
|
||||
}
|
||||
cos(T x) noexcept { return std::cos(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
tan(T x) noexcept {
|
||||
return std::tan(x);
|
||||
}
|
||||
tan(T x) noexcept { return std::tan(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
asin(T x) noexcept {
|
||||
return std::asin(x);
|
||||
}
|
||||
asin(T x) noexcept { return std::asin(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
acos(T x) noexcept {
|
||||
return std::acos(x);
|
||||
}
|
||||
acos(T x) noexcept { return std::acos(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
atan(T x) noexcept {
|
||||
return std::atan(x);
|
||||
}
|
||||
atan(T x) noexcept { return std::atan(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
atan2(T y, T x) noexcept {
|
||||
return std::atan2(y, x);
|
||||
}
|
||||
atan2(T y, T x) noexcept { return std::atan2(y, x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
sinh(T x) noexcept {
|
||||
return std::sinh(x);
|
||||
}
|
||||
sinh(T x) noexcept { return std::sinh(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
cosh(T x) noexcept {
|
||||
return std::cosh(x);
|
||||
}
|
||||
cosh(T x) noexcept { return std::cosh(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
tanh(T x) noexcept {
|
||||
return std::tanh(x);
|
||||
}
|
||||
tanh(T x) noexcept { return std::tanh(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
asinh(T x) noexcept {
|
||||
return std::asinh(x);
|
||||
}
|
||||
asinh(T x) noexcept { return std::asinh(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
acosh(T x) noexcept {
|
||||
return std::acosh(x);
|
||||
}
|
||||
acosh(T x) noexcept { return std::acosh(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, T>
|
||||
atanh(T x) noexcept {
|
||||
return std::atanh(x);
|
||||
}
|
||||
atanh(T x) noexcept { return std::atanh(x); }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, std::pair<T, T>>
|
||||
sincos(T x) noexcept {
|
||||
return {sin(x), cos(x)};
|
||||
}
|
||||
sincos(T x) noexcept { return {sin(x), cos(x)}; }
|
||||
|
||||
template < typename T >
|
||||
[[nodiscard]] std::enable_if_t<std::is_floating_point_v<T>, void>
|
||||
sincos(T x, T* s, T* c) noexcept {
|
||||
*s = sin(x);
|
||||
*c = cos(x);
|
||||
}
|
||||
sincos(T x, T* s, T* c) noexcept { *s = sin(x); *c = cos(x); }
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -465,7 +465,7 @@ namespace vmath_hpp
|
||||
}
|
||||
|
||||
//
|
||||
// Angle and Trigonometry Functions
|
||||
// Angle and Trigonometric Functions
|
||||
//
|
||||
|
||||
namespace vmath_hpp
|
||||
|
||||
@@ -14,32 +14,28 @@ namespace
|
||||
}
|
||||
|
||||
TEST_CASE("vmath/fun") {
|
||||
SECTION("Angle and Trigonometry Functions") {
|
||||
SECTION("Angle and Trigonometric Functions") {
|
||||
STATIC_REQUIRE(radians(degrees(12.13f)) == uapprox(12.13f));
|
||||
STATIC_REQUIRE(degrees(radians(12.13f)) == uapprox(12.13f));
|
||||
|
||||
(void)sin(0.f);
|
||||
(void)cos(0.f);
|
||||
(void)tan(0.f);
|
||||
{
|
||||
REQUIRE(asin(sin(1.23f)) == uapprox(1.23f));
|
||||
REQUIRE(acos(cos(1.23f)) == uapprox(1.23f));
|
||||
REQUIRE(atan(tan(1.23f)) == uapprox(1.23f));
|
||||
|
||||
(void)asin(0.f);
|
||||
(void)acos(0.f);
|
||||
(void)atan(0.f);
|
||||
(void)atan2(0.f, 0.f);
|
||||
|
||||
(void)sinh(0.f);
|
||||
(void)cosh(0.f);
|
||||
(void)tanh(0.f);
|
||||
|
||||
(void)asinh(0.f);
|
||||
(void)acosh(0.f);
|
||||
(void)atanh(0.f);
|
||||
REQUIRE(asinh(sinh(1.23f)) == uapprox(1.23f));
|
||||
REQUIRE(acosh(cosh(1.23f)) == uapprox(1.23f));
|
||||
REQUIRE(atanh(tanh(1.23f)) == uapprox(1.23f));
|
||||
}
|
||||
|
||||
{
|
||||
float out_s{}, out_c{};
|
||||
sincos(15.f, &out_s, &out_c);
|
||||
REQUIRE(out_s == uapprox(sin(15.f)));
|
||||
REQUIRE(out_c == uapprox(cos(15.f)));
|
||||
const auto [out_s2, out_c2] = sincos(15.f);
|
||||
REQUIRE(out_s2 == uapprox(sin(15.f)));
|
||||
REQUIRE(out_c2 == uapprox(cos(15.f)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +117,10 @@ TEST_CASE("vmath/fun") {
|
||||
STATIC_REQUIRE(saturate(0.5f) == uapprox(0.5f));
|
||||
STATIC_REQUIRE(saturate(1.5f) == uapprox(1.f));
|
||||
|
||||
STATIC_REQUIRE(lerp(0.f, 10.f, 0.5f) == uapprox(5.f));
|
||||
STATIC_REQUIRE(lerp(2.f, 10.f, 0.f) == uapprox(2.f));
|
||||
STATIC_REQUIRE(lerp(2.f, 10.f, 0.5f) == uapprox(6.f));
|
||||
STATIC_REQUIRE(lerp(2.f, 10.f, 1.f) == uapprox(10.f));
|
||||
|
||||
STATIC_REQUIRE(step(0.5f, 0.4f) == uapprox(0.f));
|
||||
STATIC_REQUIRE(step(0.5f, 0.6f) == uapprox(1.f));
|
||||
STATIC_REQUIRE(smoothstep(0.f, 1.f, 0.1f) == uapprox(0.028f));
|
||||
|
||||
@@ -130,7 +130,7 @@ TEST_CASE("vmath/vec_fun") {
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Angle and Trigonometry Functions") {
|
||||
SECTION("Angle and Trigonometric Functions") {
|
||||
STATIC_REQUIRE(radians(degrees(float2(12.13f))) == uapprox2(12.13f));
|
||||
STATIC_REQUIRE(degrees(radians(float2(12.13f))) == uapprox2(12.13f));
|
||||
|
||||
@@ -202,8 +202,13 @@ TEST_CASE("vmath/vec_fun") {
|
||||
|
||||
STATIC_REQUIRE(saturate(float3(-1.f,0.5,1.5f)) == uapprox3(0.f,0.5f,1.f));
|
||||
|
||||
STATIC_REQUIRE(lerp(float2(0.f), float2(10.f), 0.5f) == uapprox2(5.f));
|
||||
STATIC_REQUIRE(lerp(float2(0.f), float2(10.f), float2(0.5f)) == uapprox2(5.f));
|
||||
STATIC_REQUIRE(lerp(float2(2.f), float2(10.f), 0.f) == uapprox2(2.f));
|
||||
STATIC_REQUIRE(lerp(float2(2.f), float2(10.f), 0.5f) == uapprox2(6.f));
|
||||
STATIC_REQUIRE(lerp(float2(2.f), float2(10.f), 1.f) == uapprox2(10.f));
|
||||
|
||||
STATIC_REQUIRE(lerp(float2(2.f), float2(10.f), float2(0.f)) == uapprox2(2.f));
|
||||
STATIC_REQUIRE(lerp(float2(2.f), float2(10.f), float2(0.5f)) == uapprox2(6.f));
|
||||
STATIC_REQUIRE(lerp(float2(2.f), float2(10.f), float2(1.f)) == uapprox2(10.f));
|
||||
|
||||
STATIC_REQUIRE(step(0.5f, float2(0.4f)) == uapprox2(0.f));
|
||||
STATIC_REQUIRE(step(0.5f, float2(0.6f)) == uapprox2(1.f));
|
||||
|
||||
Reference in New Issue
Block a user