You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

186 lines
4.6 KiB

4 years ago
  1. ///////////////////////////////////////////////////////////////////////////////////
  2. /// OpenGL Mathematics (glm.g-truc.net)
  3. ///
  4. /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  5. /// Permission is hereby granted, free of charge, to any person obtaining a copy
  6. /// of this software and associated documentation files (the "Software"), to deal
  7. /// in the Software without restriction, including without limitation the rights
  8. /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. /// copies of the Software, and to permit persons to whom the Software is
  10. /// furnished to do so, subject to the following conditions:
  11. ///
  12. /// The above copyright notice and this permission notice shall be included in
  13. /// all copies or substantial portions of the Software.
  14. ///
  15. /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. /// THE SOFTWARE.
  22. ///
  23. /// @ref gtx_constants
  24. /// @file glm/gtx/constants.inl
  25. /// @date 2011-10-14 / 2012-01-25
  26. /// @author Christophe Riccio
  27. ///////////////////////////////////////////////////////////////////////////////////
  28. namespace glm
  29. {
  30. template <typename genType>
  31. GLM_FUNC_QUALIFIER genType epsilon()
  32. {
  33. return std::numeric_limits<genType>::epsilon();
  34. }
  35. template <>
  36. GLM_FUNC_QUALIFIER half epsilon()
  37. {
  38. return half(1.19209290e-007);
  39. }
  40. template <typename genType>
  41. GLM_FUNC_QUALIFIER genType zero()
  42. {
  43. return genType(0);
  44. }
  45. template <typename genType>
  46. GLM_FUNC_QUALIFIER genType one()
  47. {
  48. return genType(1);
  49. }
  50. template <typename genType>
  51. GLM_FUNC_QUALIFIER genType pi()
  52. {
  53. return genType(3.14159265358979323846264338327950288);
  54. }
  55. template <typename genType>
  56. GLM_FUNC_QUALIFIER genType root_pi()
  57. {
  58. return genType(1.772453850905516027);
  59. }
  60. template <typename genType>
  61. GLM_FUNC_QUALIFIER genType half_pi()
  62. {
  63. return genType(1.57079632679489661923132169163975144);
  64. }
  65. template <typename genType>
  66. GLM_FUNC_QUALIFIER genType quarter_pi()
  67. {
  68. return genType(0.785398163397448309615660845819875721);
  69. }
  70. template <typename genType>
  71. GLM_FUNC_QUALIFIER genType one_over_pi()
  72. {
  73. return genType(0.318309886183790671537767526745028724);
  74. }
  75. template <typename genType>
  76. GLM_FUNC_QUALIFIER genType two_over_pi()
  77. {
  78. return genType(0.636619772367581343075535053490057448);
  79. }
  80. template <typename genType>
  81. GLM_FUNC_QUALIFIER genType two_over_root_pi()
  82. {
  83. return genType(1.12837916709551257389615890312154517);
  84. }
  85. template <typename genType>
  86. GLM_FUNC_QUALIFIER genType one_over_root_two()
  87. {
  88. return genType(0.707106781186547524400844362104849039);
  89. }
  90. template <typename genType>
  91. GLM_FUNC_QUALIFIER genType root_half_pi()
  92. {
  93. return genType(1.253314137315500251);
  94. }
  95. template <typename genType>
  96. GLM_FUNC_QUALIFIER genType root_two_pi()
  97. {
  98. return genType(2.506628274631000502);
  99. }
  100. template <typename genType>
  101. GLM_FUNC_QUALIFIER genType root_ln_four()
  102. {
  103. return genType(1.17741002251547469);
  104. }
  105. template <typename genType>
  106. GLM_FUNC_QUALIFIER genType e()
  107. {
  108. return genType(2.71828182845904523536);
  109. }
  110. template <typename genType>
  111. GLM_FUNC_QUALIFIER genType euler()
  112. {
  113. return genType(0.577215664901532860606);
  114. }
  115. template <typename genType>
  116. GLM_FUNC_QUALIFIER genType root_two()
  117. {
  118. return genType(1.41421356237309504880168872420969808);
  119. }
  120. template <typename genType>
  121. GLM_FUNC_QUALIFIER genType root_three()
  122. {
  123. return genType(1.73205080756887729352744634150587236);
  124. }
  125. template <typename genType>
  126. GLM_FUNC_QUALIFIER genType root_five()
  127. {
  128. return genType(2.23606797749978969640917366873127623);
  129. }
  130. template <typename genType>
  131. GLM_FUNC_QUALIFIER genType ln_two()
  132. {
  133. return genType(0.693147180559945309417232121458176568);
  134. }
  135. template <typename genType>
  136. GLM_FUNC_QUALIFIER genType ln_ten()
  137. {
  138. return genType(2.30258509299404568401799145468436421);
  139. }
  140. template <typename genType>
  141. GLM_FUNC_QUALIFIER genType ln_ln_two()
  142. {
  143. return genType(-0.3665129205816643);
  144. }
  145. template <typename genType>
  146. GLM_FUNC_QUALIFIER genType third()
  147. {
  148. return genType(0.3333333333333333333333333333333333333333);
  149. }
  150. template <typename genType>
  151. GLM_FUNC_QUALIFIER genType two_thirds()
  152. {
  153. return genType(0.666666666666666666666666666666666666667);
  154. }
  155. template <typename genType>
  156. GLM_FUNC_QUALIFIER genType golden_ratio()
  157. {
  158. return genType(1.61803398874989484820458683436563811);
  159. }
  160. } //namespace glm