Blender V4.3
BLI_math_numbers.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
13#include <type_traits>
14
15#include "BLI_utildefines.h"
16
18
19template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
20inline constexpr T e_v = 2.718281828459045235360287471352662498L;
21
22/* log_2 e */
23template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
24inline constexpr T log2e_v = 1.442695040888963407359924681001892137L;
25
26/* log_10 e */
27template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
28inline constexpr T log10e_v = 0.434294481903251827651128918916605082L;
29
30/* pi */
31template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
32inline constexpr T pi_v = 3.141592653589793238462643383279502884L;
33
34/* 1/pi */
35template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
36inline constexpr T inv_pi_v = 0.318309886183790671537767526745028724L;
37
38/* 1/sqrt(pi) */
39template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
40inline constexpr T inv_sqrtpi_v = 0.564189583547756286948079451560772586L;
41
42/* log_e 2 */
43template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
44inline constexpr T ln2_v = 0.693147180559945309417232121458176568L;
45
46/* log_e 10 */
47template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
48inline constexpr T ln10_v = 2.302585092994045684017991454684364208L;
49
50/* sqrt(2) */
51template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
52inline constexpr T sqrt2_v = 1.414213562373095048801688724209698079L;
53
54/* sqrt(3) */
55template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
56inline constexpr T sqrt3_v = 1.732050807568877293527446341505872367L;
57
58/* 1/sqrt(3) */
59template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
60inline constexpr T inv_sqrt3_v = 0.577350269189625764509148780501957456L;
61
62/* The Euler-Mascheroni constant */
63template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
64inline constexpr T egamma_v = 0.577215664901532860606512090082402431L;
65
66/* The golden ratio, (1+sqrt(5))/2 */
67template<typename T, BLI_ENABLE_IF((std::is_floating_point_v<T>))>
68inline constexpr T phi_v = 1.618033988749894848204586834365638118L;
69
70inline constexpr double e = e_v<double>;
71inline constexpr double log2e = log2e_v<double>;
72inline constexpr double log10e = log10e_v<double>;
73inline constexpr double pi = pi_v<double>;
74inline constexpr double inv_pi = inv_pi_v<double>;
75inline constexpr double inv_sqrtpi = inv_sqrtpi_v<double>;
76inline constexpr double ln2 = ln2_v<double>;
77inline constexpr double ln10 = ln10_v<double>;
78inline constexpr double sqrt2 = sqrt2_v<double>;
79inline constexpr double sqrt3 = sqrt3_v<double>;
80inline constexpr double inv_sqrt3 = inv_sqrt3_v<double>;
81inline constexpr double egamma = egamma_v<double>;
82inline constexpr double phi = phi_v<double>;
83
84} // namespace blender::math::numbers
constexpr double inv_sqrtpi
constexpr double inv_sqrt3