Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions source/runtime/core/public/maths/base/Scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "concepts/Concepts.hpp"
#include "CoreMinimal.hpp" // IWYU pragma: keep
#include "maths/base/Constants.hpp"
#include <cmath>

namespace gp::math
{
Expand Down Expand Up @@ -230,4 +231,24 @@ GP_NODISCARD constexpr T nextPowerOfTwo(T value) noexcept
return value + 1;
}

/// @brief Returns the square root of a value.
/// @tparam T Floating-point type.
/// @param[in] value The value to compute the square root of.
/// @return The square root of @p value.
template <concepts::IsFloatingPoint T>
GP_NODISCARD constexpr T sqrt(const T value) noexcept
{
return std::sqrt(value);
}

/// @brief Returns the reciprocal of the square root of a value.
/// @tparam T Floating-point type.
/// @param[in] value The value to compute the inverse square root of.
/// @return The reciprocal of the square root of @p value.
template <concepts::IsFloatingPoint T>
GP_NODISCARD constexpr T inverseSqrt(const T value) noexcept
{
return static_cast<T>(1) / sqrt(value);
}

} // namespace gp::math
34 changes: 34 additions & 0 deletions source/runtime/core/public/maths/base/Tresholds.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) - Graphical Playground. All rights reserved.
// For more information, see https://graphical-playground/legal
// mailto:support AT graphical-playground DOT com

#pragma once

#include "concepts/Concepts.hpp"
#include "CoreMinimal.hpp" // IWYU pragma: keep

namespace gp::math
{

/// @brief A struct containing threshold values for various mathematical operations.
/// @tparam T The floating-point type for the threshold values.
template <concepts::IsFloatingPoint T>
struct tresholds final
{
static constexpr T pointOnPlane = static_cast<T>(0.10);
static constexpr T pointOnSide = static_cast<T>(0.20);
static constexpr T pointsAreSame = static_cast<T>(0.00002);
static constexpr T pointsAreNear = static_cast<T>(0.015);
static constexpr T normalsAreSame = static_cast<T>(0.00002);
static constexpr T uvsAreSame = static_cast<T>(0.0009765625);
static constexpr T vectorsAreNear = static_cast<T>(0.0004);
static constexpr T splitPolyWithPlane = static_cast<T>(0.25);
static constexpr T splitPolyPrecisely = static_cast<T>(0.01);
static constexpr T zeroNormSquared = static_cast<T>(0.0001);
static constexpr T normalsAreParallel = static_cast<T>(0.999845);
static constexpr T normalsAreOrthogonal = static_cast<T>(0.017455);
static constexpr T vectorNormalized = static_cast<T>(0.01);
static constexpr T quatNormalized = static_cast<T>(0.01);
};

} // namespace gp::math
Loading
Loading